PHP Exercises
You can test your PHP skills with W3Schools' Exercises.
Exercise Categories
There are 3 to 5 questions in each exercise category:
PHP
Introduction
PHP
Syntax
PHP
Comments
PHP
Variables
PHP
Variable Scope
PHP
Echo and Print
PHP
Data Types
PHP
Strings
PHP
Modify Strings
PHP
Concatenate Strings
PHP
Slice Strings
PHP
Numbers
PHP
Casting
PHP
Math
PHP
Constants
PHP
Operators
PHP
If Statement
PHP
If Operators
PHP
If...Else
PHP
Switch
PHP
Loops
PHP
While Loops
PHP
Do While Loops
PHP
For Loops
PHP
Foreach Loops
PHP
Functions
PHP
Arrays
PHP
Indexed Arrays
PHP
Associative Arrays
PHP
Create Arrays
PHP
Access Arrays
PHP
Update Arrays
PHP
Add Array Items
PHP
Remove Array Items
PHP
Sorting Arrays
PHP
$GLOBALS
PHP
$_REQUEST
PHP
Reqular Expressions
PHP
Forms
PHP
Dates
PHP
Includes
PHP
File Handling
PHP
Cookies
PHP
Session Variables
PHP
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 on 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. 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.