<?php // == is an operator which test // equality and returns a boolean if ($action == "show_version") { echo "The version is 1.23"; }
// this is not necessary... if ($show_separators == TRUE) { echo "<hr>\n"; }
// ...because instead, this can be used: if ($show_separators) { echo "<hr>\n"; } ?>
Converting to boolean
To explicitly convert a value to boolean, use the
(bool) or (boolean) casts. However, in
most cases the cast is unncecessary, since a value will be automatically
converted if an operator, function or control structure requires a
boolean argument.