PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source server-side scripting language designed primarily for web development, powering everything from simple blogs to the world's largest websites. Originally created in 1994, PHP has evolved into a mature, feature-rich language with strong typing, modern object-oriented capabilities, and a JIT compiler for performance. While it runs on the server and generates HTML sent to the client, understanding PHP's syntax patterns, type system, and security best practices is essentialβespecially as the language continues to evolve rapidly: PHP 8.4 (November 2024) added property hooks, lazy objects, and new array functions, while PHP 8.5 (November 2025) introduced the pipe operator, clone with, and a built-in RFC 3986/WHATWG URI extension.
What This Cheat Sheet Covers
This topic spans 30 focused tables and 332 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Data Types
| Type | Example | Description |
|---|---|---|
$num = 42; | β’ Whole numbers (positive, negative, or zero) β’ supports decimal, hexadecimal (0x prefix), octal (0o prefix), and binary (0b prefix) notation. | |
$pi = 3.14159; | β’ Floating-point numbers; also known as double β’ supports scientific notation ( 1.5e3). | |
$name = "Alice"; | β’ Sequence of characters; single quotes (literal) or double quotes (interpolated) β’ also supports heredoc and nowdoc syntax for multi-line strings. | |
$active = true; | β’ Represents true or false; case-insensitive β’ 0, "", null, and empty arrays evaluate to false in boolean context. | |
$arr = [1, 2, 3]; | β’ Ordered map holding values indexed by numeric or string keys β’ supports both indexed and associative arrays. |