What is PHP?
What PHP is, why it still powers most of the web, and how it fits into a request/response cycle.
2 min read
PHP (PHP: Hypertext Preprocessor) is a server-side scripting language built specifically for the web. Where HTML describes a page's structure and CSS its style, PHP is what runs on the server, before any of that ever reaches a browser — generating the HTML dynamically, talking to a database, handling a form submission, checking who's logged in.
Server-side means it runs before the browser sees anything
<?php
$name = "Amara";
echo "<h1>Hello, {$name}!</h1>";
?>When a browser requests a .php file, the web server runs this code first, top to bottom, and sends the result — plain HTML — to the browser. The visitor never sees $name = "Amara";; they only ever receive <h1>Hello, Amara!</h1>. This is the core model every PHP framework builds on: PHP code executes, produces output, and that output is what gets sent over the network.
PHP is why most of the web looks the way it does
An enormous share of existing websites run on PHP, in large part because of WordPress (itself written in PHP) and because PHP hosting has historically been cheap and widely available. Modern PHP — the version most frameworks target today — is a different language from the PHP of the mid-2000s: it has strong typing options, a real package manager, and modern object-oriented features, even though a lot of that reputation-forming old code still exists on the web.
A minimal PHP file
<?php
// This is a comment
$greeting = "Welcome to PHP";
echo $greeting;Every PHP block starts with <?php and can optionally end with ?> (usually omitted at the end of a pure-PHP file, since a stray newline after ?> can cause subtle bugs). echo is the most basic way to output text — everything printed with echo becomes part of the HTML response.
Mixing PHP with HTML
<!DOCTYPE html>
<html>
<body>
<h1>Product List</h1>
<?php foreach ($products as $product): ?>
<p><?= $product ?></p>
<?php endforeach; ?>
</body>
</html>PHP was designed to be embedded directly inside HTML — you can drop in and out of PHP mode with <?php ... ?> as many times as needed on one page. <?= $product ?> is shorthand for <?php echo $product; ?>, commonly used for printing a single value inline. This embedding style is less common in modern frameworks (which usually use a templating engine instead), but it's still exactly what's happening under the hood.
What the rest of this course covers
From here, this course builds up PHP's syntax, functions, and object-oriented features, before ending with the frameworks (Laravel, Symfony) that turn raw PHP into the structured, secure, and maintainable applications running in production today.
Test what you just learned
4 quick questions. Get all of them right to unlock the next lesson.
You can take the quiz without an account — logging in just lets your result count toward your progress.