Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Question Mark ?

? is a character, used in various situations.

  • Ternary operator: $a ? $b : $c
  • Short ternary operator: $a ?: $c
  • Coalesce 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

?>

Documentation