Yoda Condition

Yoda condition is a way to write condition by using any literal value on the left, instead of the right.

This prevents errors where the comparison operator is shortened, and turned into an assignation, which is usually true.

<?php

    // Yoda condition
    if (0 == $a) {}

    // Assignation, instead of comparison and bug
    if ($a = 0) {}

?>

Documentation

See also Why using Yoda conditions you should probably not be and Rule yoda_style.

Related : Coding Conventions, Design Pattern, Condition, Explicit Boolean Comparison