PHPPHP

Learn PHP – all lessons

16 lessons from beginner to advanced, building on each other and with code examples.

Beginner
1

Hello World & PHP Tags

Your first PHP script, echo and how PHP works together with HTML.

2

Variables, Types & Strings

Variables with $, the basic types and the difference between '...' and "...".

3

Conditions, ?? and match

if/elseif, ternary, null coalescing and the modern match expression.

4

Loops: for, while, foreach

Repetition over numbers and arrays.

5

Functions with Types & Named Arguments

Parameters, return types, default values, variadics and arrow functions.

6

Arrays: Lists and Maps in One

The universal PHP array, its functions and destructuring.

Intermediate
7

Strings, Files & JSON

Processing text (including umlauts), reading/writing files and handling JSON.

8

Forms, GET & POST

Receiving input, validating it, outputting it safely and finishing with Post/Redirect/Get.

9

Classes, Interfaces & Traits

Object-oriented programming with constructor promotion, inheritance, interfaces and traits.

10

Enums & readonly

Type-safe choice values and immutable objects – two highlights of PHP 8.1+.

11

Exceptions & Error Handling

try/catch/finally, custom exceptions, Error vs. Exception and strict_types.

12

Sessions, Cookies & Login

Storing state between requests and building a secure login.

13

Composer, Namespaces & Autoloading

Installing packages and organizing your own code cleanly into namespaces.

Advanced
14

Database with PDO

Prepared statements, transactions and clean queries with PDO.

15

Security: XSS, SQL Injection, Passwords

The most important web attacks and how to prevent them in PHP.

16

Modern PHP: Generators, Attributes, Fibers & Tooling

Memory-friendly data streams, attributes, first-class callables, fibers and quality tools.