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 best practices for storing and retrieving user input data in PHP when using multiple form pages?
When using multiple form pages in PHP, it is important to store user input data temporarily so it can be retrieved and displayed on subsequent pages. One common...
session variables form submission data validation -
In PHP, what are the advantages and disadvantages of using different methods, such as array_chunk(), array_rand(), and implode(), for handling arrays and random numbers?
When working with arrays in PHP, it is important to choose the right method based on the specific task at hand. For example, if you need to split an array into...
PHP array_chunk() array_rand() -
What are some common approaches to combining array elements in PHP?
One common approach to combining array elements in PHP is by using the `implode()` function, which concatenates array elements into a string with a specified de...
array_merge array_combine array_intersect