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 the localization settings in MySQL affect the output of date functions in PHP?
When the localization settings in MySQL are different from the default settings in PHP, it can cause date functions to output incorrect results or errors. To so...
MySQL localization settings date functions -
How can the strlen() function be used to limit the output of a string in PHP?
To limit the output of a string in PHP using the strlen() function, you can simply check the length of the string and truncate it if it exceeds a certain limit....
strlen function limit -
Are there best practices for using PHP to safeguard images on a website?
To safeguard images on a website using PHP, it is important to prevent direct access to the image files by users. One common approach is to store the images out...
image upload file validation image manipulation