Question Mark ?¶
? is a character, used in various situations:
Ternary operator:
$a ? $b : $cShort ternary operator:
$a ?: $cCoalesce operator:
$a ??Null type,
function foo(?int $int) {}As a quantifier in regex, 0 or 1
As a quantifier with
fnmatch(), 0 or 1.
<?php
$a = 1;
echo a ? 'b' : 'c'; // c
?>
Related : Ternary Operator, Coalesce Operator, Type System, Regular Expression, fnmatch()