PHP
A server-side scripting language powering a large share of the web.
CurrentbeginnerBeginner-friendlyFull course available
Overview
PHP is a server-side scripting language designed for web development, embedded directly in HTML output. It powers a very large share of the web (including WordPress) and has modernized substantially since its early reputation, with strong typing options and a mature framework ecosystem (Laravel) in current versions.
- What it is
- A server-side scripting language that generates HTML output dynamically per request.
- Why it's used
- It's simple to deploy (nearly every host supports it), powers WordPress and Laravel, and has a huge existing codebase to maintain.
- Where it fits
- Server-side, generating pages or APIs; commonly paired with MySQL.
Core concepts
- Embedding PHP in HTML
- Variables and functions
- Arrays
- Superglobals ($_GET, $_POST)
- Working with a database
Example
PHP executes on the server and outputs plain HTML to the browser -- htmlspecialchars() here escapes user input before it's rendered, a basic XSS defense.
<?php
$name = $_GET["name"] ?? "world";
?>
<h1>Hello, <?= htmlspecialchars($name) ?>!</h1>Common use cases
- WordPress sites and plugins
- Laravel-based web applications
- Legacy and modern server-rendered sites alike
Project ideas
- A simple contact form that validates input and writes to a file or database