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
-
How can PHP be used to ensure the format of an email address is valid before sending an email?
To ensure the format of an email address is valid before sending an email in PHP, you can use the filter_var() function with the FILTER_VALIDATE_EMAIL filter. T...
PHP email validation regular expressions -
What are some common methods in PHP to extract meta-information from images?
To extract meta-information from images in PHP, you can use the getimagesize() function to retrieve details such as image width, height, MIME type, and more. An...
PHP image processing getimagesize -
How can the performance impact of database queries within nested loops be optimized in PHP scripts?
When database queries are executed within nested loops in PHP scripts, it can significantly impact performance due to the repeated connection and query executio...
PHP database queries nested loops