PHP — Command Reference
PHP's most used commands and functions — a classic of web servers. Each with an explanation and a working example. (Examples start with <?php.)
8 categories · 33 commands
🖥️
Output
Printing to the screen and embedding variables in text.
echoEmbedding variables in text📦
Variables
Variables and constants with $.
$variabledefine() / const🔢
Numbers & Math
Arithmetic operations and mathematical functions.
Arithmetic ( + - * / % ** )round() / floor() / ceil()max() / min() / abs()rand() / mt_rand()✍️
String
Text length, transformation, splitting, and searching.
strlen()strtoupper() / strtolower()trim()str_replace()+3📋
Array
Working with indexed and associative (keyed) arrays.
array / [ ]array_push() / []in_array() / array_search()sort() / rsort()+3🔁
Condition & Loop
Decision-making and repetition structures.
if / elseif / elseTernary operator ( ?: )forforeach+1🧩
Function
Defining your own functions.
functionDefault parameterArrow function ( fn )🔄
Type & Conversion
Type casting and checking.
(int) / intval() / floatval()(string) / strval()is_numeric() / gettype()