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

Colon

Colons are used in a variety of situations:

  • With named parameters, to separate the name from the value
  • With labels, for goto
  • With ternary operator, separated or not from the question mark
  • In include_path and open_basedir, double-colon is used as a separator

The double colon is a distinct operator.

<?php

    goto there;
    there:

    foo(a: 3); // 

    $b = $a ? 'a' : 'b';
    $c = $c ?: 'a';

?>

Documentation

See Also