PHP questions, answered with working code.
Search explained answers, or work through a guide from your first script to namespaces.
Popular: password_hash · PDO · sessions · array_map · json_decode
Guides
Introduction to PHP
Syntax, variables, arrays, functions, forms and basic security.
14 sections
IntermediateSessions & Cookies
Keep state between requests: creating cookies, storing and destroying session data.
9 sections
AdvancedNamespaces
Organise larger codebases, avoid name collisions and understand name resolution.
7 sections
From the knowledge base
-
What is the standard way to create line breaks in text emails using PHP?
In order to create line breaks in text emails using PHP, the standard way is to use the "\r\n" characters to represent a new line. This ensures that the email c...
PHP line breaks text emails -
What tools or libraries can be helpful for parsing email content and interacting with a MySQL database in PHP for this specific task?
To parse email content and interact with a MySQL database in PHP, you can use the PHP IMAP extension to fetch emails from a mailbox, a library like PHPMailer to...
PHP email parsing MySQL database -
What potential pitfalls should be considered when handling session data in PHP?
One potential pitfall when handling session data in PHP is the risk of session fixation attacks, where an attacker can force a user to use a known session ID. T...
session data security vulnerabilities session hijacking