Learn modern PHP 8.5 from your first echo to classes, exceptions and array functions, with every exercise checked as you go.
15 lessons, 29 exercises. Runs PHP 8.5.
Not started
Hello, output
Print text with echo, write comments, and see how PHP runs a script from top to bottom.
Values and variables
Store values in $variables, meet PHP's basic types, define constants and put values inside strings.
Reading input and arithmetic
Read lines from standard input, convert them to numbers, and calculate with PHP's arithmetic operators.
Making decisions
Choose what your program does with if, elseif, else and match, using strict comparisons and boolean logic.
Loops
Repeat work with for, while, do-while and foreach, and control loops with break and continue.
Functions
Write reusable functions with typed parameters, default values, named arguments and return types, and learn how scope works.
Arrays
Store many values in PHP arrays, used both as ordered lists and as key-value maps, and loop over them with foreach.
Strings and a small project
Search, slice, clean and format text with PHP's string functions, then build a small receipt printer.
Handling errors
Throw and catch exceptions, understand PHP's Exception and Error families, and define your own exception classes.
Structuring data with classes
Group data and behaviour into classes with typed properties, constructor promotion, visibility and readonly values.
Recursion
Solve problems by having a function call itself on a smaller piece, and avoid repeated work with a cache.
Sorting and searching
Pick the right PHP sort function, write custom comparisons with the spaceship operator, and search sorted data with binary search.
Counting, grouping and sets
Use associative arrays to count and group data, and PHP's array functions to work with sets.
Array functions and the pipe operator
Transform associative arrays with array_map, array_filter and array_reduce, write short callbacks with fn, and chain steps with PHP 8.5's pipe operator.
Final project: an inventory manager
Combine classes, exceptions, associative arrays, sorting and formatting into a complete command-driven inventory program.
Your progress is saved in this browser. Sign in to keep it on every device.