PHP Reference ยท Concepts and Reference
PHP glossary
A glossary of key PHP terms: callable, closure, namespace, autoloading, SAPI, opcode, trait, enum, generator, superglobal, PDO and more, with runnable examples.
PHP has plenty of vocabulary that newcomers meet all at once. This glossary defines the terms you will see in the manual, in error messages and in framework documentation, in plain language. Terms link to deeper pages where they exist.
Read it once, then use it as a lookup. The two examples show terms that are easier to see than to read about: the forms of a callable, and how a closure captures variables.
<?php $greet = fn(string $n) => "Hello $n"; // arrow function: a closure echo $greet("Ada");
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.
Terms
| Term | Meaning |
|---|---|
| Argument / parameter | A parameter is the variable in a function definition; an argument is the value passed in the call. |
| Array | An ordered map of keys (ints or strings) to values. Also serves as a list, set, stack and queue. |
| Attribute | Structured metadata written as #[Name] and read through Reflection (PHP 8.0). |
| Autoloading | Loading a class file on first use, through spl_autoload_register() or Composer. |
| Callable | Anything that can be called: a function name, [$object, 'method'], 'Class::method', a closure or an invokable object. |
| Closure | An anonymous function object that can capture variables from its surroundings. fn is the short form. |
| Composer | The dependency manager. Installs packages and generates the autoloader. |
| Constant | A value that cannot change, defined with const or define(). |
| Coercion | Automatic type conversion; strict types turn most of it into a TypeError. |
| Enum | A type with a fixed set of cases (PHP 8.1), optionally backed by int or string. |
| Error vs. Exception | Both implement Throwable. Error signals engine problems (type errors, undefined functions); Exception is for application conditions. |
| Fiber | A pausable execution stack for cooperative multitasking (8.1). |
| Generator | A function with yield that produces values lazily. |
| Heredoc / nowdoc | Multi-line string syntaxes: heredoc interpolates, nowdoc does not. |
| Interface | A contract of method signatures a class promises to implement. |
| Magic method | A special __name method PHP calls automatically, such as __construct() or __toString(). |
| Namespace | A named scope that prevents class and function name clashes. |
| Opcache / opcode | PHP compiles scripts to opcodes; OPcache keeps them in shared memory so scripts are not recompiled each request. |
| PDO | PHP Data Objects, a uniform database access layer with prepared statements. |
| PSR | A PHP-FIG recommendation such as PSR-4 or PSR-12. |
| Reference | An alias for another variable, made with &. Not the same as a pointer. |
| Reflection | APIs that inspect classes, functions and attributes at runtime. |
| SAPI | Server API: how PHP is run (cli, fpm-fcgi, apache2handler, cgi-fcgi). |
| Scope | Where a variable is visible. Functions have their own scope; use parameters, global or use. |
| SPL | Standard PHP Library: data structures, iterators, exceptions and autoloading. |
| Superglobal | An always-available array such as $_GET, $_POST, $_SERVER or $_SESSION. |
| Trait | A reusable group of methods and properties mixed into classes. |
| Type juggling | PHP's implicit conversion between types. |
| Union type | A type that allows several types, like `int |
| Visibility | public, protected or private access for properties and methods. |
Usage notes
- Terms like "pass by reference" and "object handle" confuse beginners. Objects are passed as handles (the handle is copied, the object is shared), while
&makes a variable an alias. - Manual pages say "language construct" for things such as
echo,issetandlist; these are syntax, not functions. - When an error message uses an unfamiliar word, search this site's reference for the function or concept first.