How this PHP track works
- Server PHP in the playground — your code runs on the dev runner with
echo,print_r, andvar_dumpfor output. Click Run to execute. - Web concepts in prose —
$_GET,$_POST, sessions, and PDO are taught with sample arrays and comments when real HTTP or a database is not available in the runner. - Prerequisites — finish HTML (forms, semantic markup) and JavaScript (functions, objects, async basics) before this track.
Use echo for strings, print_r() for arrays, and var_dump() when you need types and structure.
Install on your device (macOS, Linux, Windows)
Install PHP 8.2+ for local Laravel/WordPress practice; lesson playground runs PHP via the dev runner.
macOS
brew install php- Optional full stack: Laravel Herd or
brew install mysqlfor databases.
Linux
- Debian/Ubuntu:
sudo apt update && sudo apt install -y php-cli php-mbstring php-xml php-curl unzip - Fedora:
sudo dnf install -y php php-cli php-mbstring php-xml
Windows
winget install PHP.PHP.8.3or use XAMPP / Laravel Herd for Windows.- Add PHP to PATH if the installer does not (Settings → Environment Variables).
Verify: php -v shows PHP 8.2 or newer.
Run code on this site (Backend & language playgrounds)
- Clone or open this project locally; copy
.env.exampleto.env. - Ensure
LEARNING_RUNNER_ENABLED=trueandLEARNING_RUNNER_URL=http://127.0.0.1:9999/v1/execute. - Terminal 1:
php artisan serve(orcomposer run devfor Laravel + Vite + runner together). - Terminal 2:
npm run runner— keep it running while you click Run on server.
PHP (PHP: Hypertext Preprocessor) is a server-side scripting language built for the web. Your browser requests a URL; a web server runs PHP code, often talks to a database, and returns HTML (or JSON) as the response.
How this track differs from JavaScript in the browser
After the JavaScript track, you know variables, functions, and DOM events that run in the user's browser. PHP runs on the server before the response is sent. You use it for form handling, authentication, database queries, and generating dynamic pages.
The HTML track taught document structure and forms. PHP often produces that HTML—or fills templates with data from a database.
What you will learn
- PHP syntax: tags, variables, control flow, functions, and OOP basics
- Arrays, JSON, and superglobals like
$_GETand$_POST - Sessions, cookies, includes, and error handling for web apps
- PDO for safe database access and security fundamentals
- Composer, autoloading, and production habits
Playground setup
This topic uses the server_script profile: PHP executes on the dev runner when you click Run. Output appears in the terminal via echo, print_r, and var_dump. Web-only features (real HTTP requests, live sessions, MySQL) are simulated with sample arrays and comments—real projects need a local stack (PHP + web server + database).
Self-check
- In one sentence, where does PHP run compared to browser JavaScript?
- Why do we recommend HTML and JavaScript before this track?
Interview prep
- What is PHP in one sentence?
A server-side scripting language that generates HTTP responses—often HTML or JSON—after the web server receives a request, running before anything reaches the browser.