Learn PHP – all lessons
16 lessons from beginner to advanced, building on each other and with code examples.
Hello World & PHP Tags
Your first PHP script, echo and how PHP works together with HTML.
Variables, Types & Strings
Variables with $, the basic types and the difference between '...' and "...".
Conditions, ?? and match
if/elseif, ternary, null coalescing and the modern match expression.
Loops: for, while, foreach
Repetition over numbers and arrays.
Functions with Types & Named Arguments
Parameters, return types, default values, variadics and arrow functions.
Arrays: Lists and Maps in One
The universal PHP array, its functions and destructuring.
Strings, Files & JSON
Processing text (including umlauts), reading/writing files and handling JSON.
Forms, GET & POST
Receiving input, validating it, outputting it safely and finishing with Post/Redirect/Get.
Classes, Interfaces & Traits
Object-oriented programming with constructor promotion, inheritance, interfaces and traits.
Enums & readonly
Type-safe choice values and immutable objects – two highlights of PHP 8.1+.
Exceptions & Error Handling
try/catch/finally, custom exceptions, Error vs. Exception and strict_types.
Sessions, Cookies & Login
Storing state between requests and building a secure login.
Composer, Namespaces & Autoloading
Installing packages and organizing your own code cleanly into namespaces.
Database with PDO
Prepared statements, transactions and clean queries with PDO.
Security: XSS, SQL Injection, Passwords
The most important web attacks and how to prevent them in PHP.
Modern PHP: Generators, Attributes, Fibers & Tooling
Memory-friendly data streams, attributes, first-class callables, fibers and quality tools.