PHP for Beginners
From your first script to strings, arrays, functions, closures, classes, exceptions, Composer and how PHP answers a web request.
Tests check every exercise: in your browser and in the cloud
Quizzes are answered right on the site, so you need nothing installed to take the course. The course has no code exercises in the browser yet, so run the lesson examples on your own computer: set it up in three steps.
Install PHP
The lessons use PHP 8.5; examples also run on 8.3 and 8.4.
- Windows: download Laravel Herd for Windows, a free app that installs PHP, and run its installer. The installation guide explains the first launch.
- macOS: download Laravel Herd for macOS and follow its installation guide.
- Linux: on php.net/downloads, choose your distribution and follow the instructions for its packages. Also install the mbstring extension: on Ubuntu and Debian it is a separate package,
php8.5-mbstring, and themb_*functions of the strings theme need it. - The PHP manual has a full installation chapter for every system.
Install VS Code
Download VS Code and add the PHP Intelephense extension.
Composer (for theme 14)
Theme 14 uses Composer, the PHP package manager. Laravel Herd already includes it; on Linux, install it separately by following the Composer download page.
Syllabus
- Classes and objectsTheory
- The constructor and promotionTheory
- Quiz — two objectsQuiz
- Visibility: public, private, protectedTheory
- Quiz — private from outsideQuiz
- A variable holds an object handleTheory
- Quiz — two names for one objectQuiz
- Static members and constantsTheory
- Quiz — static and constQuiz
- readonly and __toStringTheory
- Quiz — writing to readonlyQuiz