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 advantages and disadvantages of using a calendar versus select fields for selecting a date in PHP forms?
When selecting a date in PHP forms, using a calendar can provide a more user-friendly interface for choosing dates, especially for users who may struggle with m...
calendar select fields date selection -
What are the best practices for handling user input in PHP scripts to prevent SQL injection vulnerabilities?
To prevent SQL injection vulnerabilities in PHP scripts, it is essential to use prepared statements with parameterized queries when interacting with a database....
SQL injection user input validation prepared statements -
What are some common best practices for maintaining session data in PHP applications to prevent data loss and improve user experience?
Session data in PHP applications can be maintained by properly configuring session settings, using secure session handling techniques, and implementing data val...
session data PHP applications data loss