PHP Glossary with Examples
Look up a term you met in a PHP lesson or project. The examples show what the term looks like in code, and the linked lesson puts it to work.
Values and functions
Section titled “Values and functions”| Term | What it means in PHP | Learn by doing |
|---|---|---|
| Variable | A name for a value. In $quantity = 3; the name is $quantity. | Variables and data types |
| Associative array | An array used to look up values by key, such as ['title' => 'Dune']. Read the title with $book['title']. | Arrays in PHP |
| Parameter | A named input in a function’s definition. In function double(int $n): int { return $n * 2; } the parameter is $n and the value in double(3) is an argument. | Functions and return values |
| Type declaration | A type PHP checks at a boundary, such as int $n for a parameter or : int for a return value. | PHP typing in practice |
| Closure | An anonymous function you can assign to a variable or pass around. $double = fn (int $n): int => $n * 2; stores one in $double. | Anonymous functions and arrow functions |
| Exception | An object that reports an error or an unexpected condition. throw new RuntimeException('File unavailable'); signals one. | Errors and exceptions |
Classes and packages
Section titled “Classes and packages”| Term | What it means in PHP | Learn by doing |
|---|---|---|
| Class | A definition of an object’s properties and methods. new DateTimeImmutable('2026-11-20') builds an object from the DateTimeImmutable class. | Classes and objects |
| Interface | A contract describing the public methods a class supplies. In class Report implements JsonSerializable, the class must supply jsonSerialize(). | Interfaces and inheritance |
| Trait | A reusable group of methods and properties that a class can include with a declaration such as use Timestamps; inside its class body. | Traits and namespaces |
| Namespace | A name prefix for a group of definitions. App\Reports\Summary is a different full class name from App\Billing\Summary. | Traits and namespaces |
| Dependency injection | Passing an object what it needs to do its work. In new BookRepository($pdo), the repository receives a database connection from its caller. | Follow dependencies through a Laravel feature |
| Composer | PHP’s dependency manager. composer install installs the versions recorded in composer.lock when that file is present. | Composer and dependencies |
| Autoloading | Loading a class file when its class is first needed. An app can load Composer’s autoloader with require __DIR__ . '/vendor/autoload.php'; from the project root. | Use Composer’s autoloader |
Web applications and data
Section titled “Web applications and data”| Term | What it means in PHP | Learn by doing |
|---|---|---|
| Superglobal | A built-in variable accessible inside functions as well as at the top level. $_GET['name'] ?? '' reads a query parameter with a default. | Read a form submission |
| Request and response | A browser sends a request such as GET /about. The server responds with a status, headers, and often a body such as a page. | Follow a PHP request |
| Router | Code that chooses what runs for an HTTP method and URL path. In the router lesson, $router->get('/about', $handler) registers a handler. | Build a basic HTTP router |
| Session | Data that spans requests, typically linked by an ID in a cookie. After session_start(), the app can use $_SESSION to read or write that data. | Sessions and cookies |
| Extension | An optional part of PHP that adds features. extension_loaded('pdo_sqlite') checks whether the SQLite PDO driver is available to the current process. | Compare PHP versions and extensions |
| PDO | A common PHP API for accessing databases through drivers. new PDO('sqlite::memory:') uses PDO SQLite to open a database in memory. | Query a database with PDO |
| Prepared statement | A database statement whose placeholders receive values separately. A statement like SELECT title FROM books WHERE id = :id receives a value for id at execution. | See a prepared statement in the reading list |
| Escaping | Preparing text for a particular output context. For HTML text, htmlspecialchars('A & B') produces A & B. | Render safe text in a PHP page |
| SAPI | The interface between PHP and the program running it. PHP_SAPI can report cli for a terminal or fpm-fcgi for PHP-FPM. | Compare local and hosted PHP |