Skip to content

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.

TermWhat it means in PHPLearn by doing
VariableA name for a value. In $quantity = 3; the name is $quantity.Variables and data types
Associative arrayAn array used to look up values by key, such as ['title' => 'Dune']. Read the title with $book['title'].Arrays in PHP
ParameterA 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 declarationA type PHP checks at a boundary, such as int $n for a parameter or : int for a return value.PHP typing in practice
ClosureAn 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
ExceptionAn object that reports an error or an unexpected condition. throw new RuntimeException('File unavailable'); signals one.Errors and exceptions
TermWhat it means in PHPLearn by doing
ClassA definition of an object’s properties and methods. new DateTimeImmutable('2026-11-20') builds an object from the DateTimeImmutable class.Classes and objects
InterfaceA contract describing the public methods a class supplies. In class Report implements JsonSerializable, the class must supply jsonSerialize().Interfaces and inheritance
TraitA 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
NamespaceA name prefix for a group of definitions. App\Reports\Summary is a different full class name from App\Billing\Summary.Traits and namespaces
Dependency injectionPassing 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
ComposerPHP’s dependency manager. composer install installs the versions recorded in composer.lock when that file is present.Composer and dependencies
AutoloadingLoading 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
TermWhat it means in PHPLearn by doing
SuperglobalA 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 responseA 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
RouterCode 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
SessionData 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
ExtensionAn 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
PDOA 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 statementA 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
EscapingPreparing text for a particular output context. For HTML text, htmlspecialchars('A & B') produces A & B.Render safe text in a PHP page
SAPIThe 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