Conditions

Conditions run code depending on a test: if, elseif, else. The comparison operators == and === differ: the latter also compares the type and is preferable. Tests are combined with &&, || and !, and ?? provides a default value.

Example

if ($age >= 18) {
  echo 'Majeur';
}

Related concepts

The whole glossary