PHP: Boolean

By Xah Lee. Date: .

True and False

true and false are built-in boolean type. Case does not matter. true is the same as True.

The following are all FALSE:

Example:

<?php
$x = 4;
if ($x == 4) {echo "yay";} else {echo "nay";} # yay
if (true) {echo "yay";} else {echo "nay";} # yay
if (trUe) {echo "yay";} else {echo "nay";} # yay
?>