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 are the potential drawbacks of using a loop with incorrect field indexing in PHP when fetching data from a MySQL database?
Using incorrect field indexing in a loop when fetching data from a MySQL database can lead to errors such as undefined index notices or incorrect data being dis...
PHP MySQL loop -
What are common pitfalls when executing PHP code externally without a browser?
Common pitfalls when executing PHP code externally without a browser include not setting the correct environment variables, not handling errors properly, and no...
Command line shell_exec security vulnerabilities -
How can PHP beginners effectively implement mathematical calculations, such as converting values to angles, in their code?
To implement mathematical calculations like converting values to angles in PHP, beginners can utilize built-in functions like atan2 and rad2deg. These functions...
PHP mathematical calculations angles