PHP Exercises
Exercises
Test your PHP skills with exercises from all categories:
Introduction
Syntax
Comments
Variables
Variable Scope
Echo and Print
Data Types
Strings
Modify Strings
Concatenate Strings
Slice Strings
Numbers
Casting
Math
Constants
Operators
If Statement
If Operators
If...Else
Switch
Loops
While Loops
Do While Loops
For Loops
Foreach Loops
Functions
Arrays
Indexed Arrays
Associative Arrays
Create Arrays
Access Arrays
Update Arrays
Add Array Items
Remove Array Items
Sorting Arrays
$GLOBALS
$_REQUEST
Reqular Expressions
Forms
Dates
Includes
File Handling
Cookies
Session Variables
JSON
Log in to track your progress
If you haven't already, sign up to become a W3Schooler, and get points for every exercise you complete.
As a logged-in W3Schools user you will have access to many features like having your own web page, track your learning progress, receive personal guided paths, and more.
The Exercise
We have gathered a variety of PHP exercises from most of the chapters in our PHP Tutorial.
The exercises are a mix of "multiple choice" and "fill in the blanks" questions. There are between 3 and 6 questions in each category. The answer can be found in the corresponding tutorial chapter. If you're stuck, or answer wrong, you can try again or hit the "Show Answer" button to see the correct answer.