H - Covered PHP Features
Every chapter in this book introduces a piece of PHP: a keyword, an operator, a built-in interface, a language mechanism. This appendix pulls them all into one list, each one linked to its entry in the PHP Dictionary, an independent, ever-growing reference of PHP terms, keywords, functions, and jargon. Use it the way you’d use any glossary: when a term from an earlier chapter comes back and you want the short version again, without hunting back through the chapter that first introduced it.
A handful of items below have no dictionary entry yet. They’re listed anyway, plainly, without a link.
Syntax and basics
- Opening tag
<?php: switches the parser from HTML mode into PHP mode. - Short echo tag
<?= ?>: shorthand that combines<?phpwith an immediateecho. echoandprint: output constructs, covered in Chapter 1.- String interpolation: embedding variables directly inside a double-quoted string.
- Comments and docblocks:
//,#,/* */, and the structured/** */form tools read, from Chapter 3.
Types and comparison
- Type juggling: PHP’s automatic conversion between types depending on context.
- Casting: explicit conversion with
(int),(string), and the rest. - Boolean,
gettype(),var_dump(): the scalar type system and how to inspect it, from Chapter 3. declare(strict_types=1): opts a file out of implicit scalar coercion.- Identical operator
===, equal operator==, loose comparison: the two families of comparison and where they diverge. - Spaceship operator
<=>: three-way comparison, returns-1,0, or1. - Union types: a parameter or return type expressed as
int|string. TypeError: thrown when a value doesn’t satisfy a type declaration.- Array: PHP’s one compound type doing double duty as list and map, from Chapter 8.
array_key_exists()andisset(): checking for a key versus checking for a non-null value.
Control flow
if/elseif/elseand conditional structures generally.while,do-while,for,foreach: the loop constructs, from Chapter 3.breakandcontinue: leaving or skipping ahead in a loop, including their optional numeric argument for nested loops.switchandmatch: the two branch-and-compare constructs, one a statement, one an expression, covered together in Chapter 6 and again as pattern syntax in Chapter 19.list()/ array destructuring and destructuring generally: unpacking an array into separate variables in one step, from Chapter 19.
Functions and closures
- Function declarations, return type declarations, and default parameter values.
void: a return type declaring that a function returns nothing meaningful.- Named arguments: calling a function by parameter name instead of position.
- Passing by reference versus passing by value: whether a function can modify the caller’s variable.
- Anonymous functions and closures: functions as values, with variables captured via
use, from Chapter 15. - Arrow functions (
fn): single-expression closures with implicit capture of the outer scope. - First-class callable syntax
foo(...): converting a named function or method reference into a realClosure. - Generators and
yield: functions that produce values lazily, one at a time, from Chapter 15.
Classes and objects
- Class declarations,
new,instanceof,clone: the basic vocabulary of object creation. - Visibility (
public,protected,private): controlling access to properties and methods. - Constructor property promotion and
readonlyproperties: shorthand construction and write-once properties, from Chapter 5. - Typed properties: declaring a property’s type up front.
staticproperties and methods, static variables, and late static binding: the several unrelated jobs thestatickeyword does.- Inheritance,
extends, andparent::: building one class on top of another, from Chapter 17. - Abstract classes and abstract methods: base classes that can’t be instantiated on their own.
- Interfaces and traits: shared contracts versus shared implementation, from Chapter 11.
- Constructor (
__construct), destructor (__destruct), and other magic methods:__toString(),__get()/__set(),__call(), covered in Chapter 17. - Generics, via docblocks: PHP has no native generics, so static analysis tools read the type from a comment instead, discussed in Chapter 11.
Enums
Namespaces and autoloading
- Namespaces and
useimports: organizing and importing names, from Chapter 7. - Autoloading: loading class files on demand instead of with a pile of
requirestatements. - PSR-4: the autoloading standard Composer implements, covered in Chapter 7. Not yet in the dictionary; only mentioned there in passing.
Error handling
Exception,Error,Throwable: PHP’s two parallel throwable hierarchies, from Chapter 9.try/catch/finallyandDivisionByZeroError: catching and handling failure.RuntimeException: one of PHP’s built-in exception subclasses, used as a base in the CLI project starting Chapter 14.- Custom exception classes (
extends Exception): a common idiom, but not yet its own dictionary entry.
Web and databases
- Superglobals,
$_GET,$_POST, and$_SERVER: reading a web request’s data, from Chapter 10. htmlspecialchars()and XSS: escaping output to stop an attacker’s markup from running in someone else’s browser, from Chapter 10.- CSRF: forged cross-site requests, named but not defended against in this book, from Chapter 10.
- PDO,
PDOException, and SQLite3: a consistent, file-based way to talk to a database, from Chapter 10. - Prepared statements and SQL injection: separating a query’s structure from its values to stop an attacker from rewriting the query.
Debugging
var_dump(),print_r(), andvar_export(): printing a value’s structure (and, forvar_dump(), its type) while chasing a bug, from Chapter 13.- Xdebug: a step debugger and profiler, pausing execution at a breakpoint instead of guessing where to print, from Chapter 13.
- Profiling: measuring where a script actually spends its time, one of Xdebug’s other jobs.
Concurrency
pcntl: the extension behind forking and controlling separate OS processes.
Reflection and attributes
- Reflection: inspecting classes, methods, properties, and attributes at runtime, from Chapter 20.
- Magic constants (
__CLASS__,__FUNCTION__,__METHOD__,__LINE__,__FILE__): compile-time constants describing the code’s own location. - Attributes
#[...]: structured metadata attached to code and read back through Reflection, from Chapter 20.
Built-in interfaces
Countable: letscount()work on a custom object.ArrayAccess: enables square-bracket access on a custom object.IteratorandIteratorAggregate: the two ways to make an object work inforeach, from Chapter 20.
Odds and ends
global: pulling a variable in from the global scope.- Copy-on-write: why passing an array by value is cheap until something actually writes to it, from Chapter 4.
- Garbage collection: how PHP reclaims memory from objects nobody references anymore.
assert(): a debug-time sanity check, from Chapter 12.- PHPUnit: the testing framework used throughout the book’s later chapters.
getenv()and$_ENV: reading environment variables, from Chapter 14.fwrite(STDERR, ...): writing to standard error instead of standard output.- Output buffering: capturing generated output into a buffer instead of sending it immediately.
register_shutdown_function(): a callback PHP guarantees to run at the end of a script, from Chapter 21.$thisandSTDIN: both used constantly from Chapter 2 onward, neither has its own dictionary entry yet.random_int(): PHP’s cryptographically secure random integer function, also not yet listed.
The gaps are worth noticing as much as the links. A few things this book leans on hard ($this, STDIN, PSR-4, custom exception classes) don’t have an entry in the dictionary yet. If you find yourself explaining one of them to someone else, that explanation is most of a dictionary entry already.