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

Precedence

Precedence organizes the way operators are executed, when they are mixed in the same expression.

For example, 1 + 2 * 3 will produce 7, since * has a higher precedence than +.

Every operator has a precedence, and when they have the same precedence, the rightmost one yield to the leftmost one.

Precedence offers some reading surprises to human readers. For example, ! $trunk instanceof \Elephpant really applies instanceof first, and && has a higher priority than and, even though they perform the same function.

<?php

var_dump(!$trunk instanceof \Elephpant);
var_dump($tusk = 1 and 2);

?>

Documentation

See Also