Server-Side Scripting for the Web
"PHP's defining characteristic: it's designed to be embedded directly in HTML. This makes it a templating language as much as a programming language."
CSE 135 — Full Overview | Review Questions
A server-side language designed to be embedded in HTML.
Created by Rasmus Lerdorf in 1995 as "Personal Home Page" tools. PHP (PHP: Hypertext Preprocessor) is designed to be embedded directly in HTML.
<?php ?> blocks, replacing them with output. The browser receives pure HTML — it never sees PHP code. This makes PHP a templating language as much as a programming language.
The mod_php request flow and the per-request model.
PHP runs inside Apache as a module. Apache receives the request, hands the .php file to the PHP interpreter, and returns the generated HTML.
app.listen(3000)Market dominance and learning advantages.
/cart.php → cart.php$_GET, $_POST make request data obvioussession_start() just works.php files. No npm install, no process managers, no build steps. This makes the connection between code and result immediate and clear.
Variables, control structures, superglobals, and common operations.
Variables start with $, strings use . for concatenation, and double-quoted strings interpolate variables directly.
| Superglobal | Contains | Example |
|---|---|---|
$_GET | URL query parameters | $_GET['id'] from ?id=42 |
$_POST | Form data (POST method) | $_POST['username'] |
$_SESSION | Session data | $_SESSION['user_id'] |
$_COOKIE | Cookie values | $_COOKIE['theme'] |
$_SERVER | Server/request info | $_SERVER['REQUEST_METHOD'] |
Composer, frameworks, ORMs, testing, and PHP 8+.
composer.json5 concepts of PHP server-side development in one table.
| Concept | Key Takeaway |
|---|---|
| What is PHP? | A server-side language embedded in HTML. The server processes <?php ?> blocks and the browser receives pure HTML. |
| Execution Model | PHP runs inside Apache (mod_php). Each request starts fresh — variables don't persist. Sessions and databases handle state. |
| Why PHP? | ~77% market share, WordPress, simple deployment. URL-to-file mapping and superglobals make concepts transparent. |
| Syntax Essentials | $ variables, superglobals ($_GET, $_POST, $_SESSION), and built-in functions for sessions, cookies, and JSON. |
| Ecosystem | Composer, Laravel/Symfony, Eloquent/Doctrine, PHPUnit, PHP 8+. Fundamentals apply regardless of framework. |