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 pitfalls of implementing a search function in PHP that searches through files?
One potential pitfall of implementing a search function in PHP that searches through files is the risk of exposing sensitive information or compromising securit...
file handling search algorithm memory consumption -
Are there any best practices or recommended approaches for handling and replacing strings in PHP texts?
When handling and replacing strings in PHP texts, it is recommended to use built-in functions such as `str_replace()` or `preg_replace()` for simple string repl...
string manipulation str_replace preg_replace -
How does the use of \d differ from [0-9] in regular expressions in PHP, and when should each be used?
In regular expressions in PHP, \d matches any digit character, equivalent to [0-9]. The main difference is that \d is a shorthand for matching any digit, while...
regular expressions \d [0-9]