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 some best practices for managing file paths in PHP scripts when files are located in different directories?
When working with files located in different directories in PHP scripts, it is important to use relative paths to ensure portability and flexibility. One best p...
file paths PHP scripts directories -
Are there best practices for including text in a PHP file within an HTML page?
When including text in a PHP file within an HTML page, it is best practice to use PHP echo or print statements to output the text. This ensures that the text is...
PHP HTML include -
What are the best practices for ensuring secure URL generation and access control in PHP applications, particularly when dealing with sensitive user data like IDs?
To ensure secure URL generation and access control in PHP applications when dealing with sensitive user data like IDs, it is important to use proper encryption...
URL generation access control sensitive data