So there\'s this page on the php site which shows the result of comparing different values:
http://php.net/manual/en/types.comparisons.php
This is a helpful refe
For casting directly to a boolean this is how it works.
Then these rules for comparing variables of the same type:
For variable of different types the type that is higher on the above list is cast to the one that is lower then the comparison is made.
===
and !==
operators don't cast prior to comparing but you should note objects are only ===
if they are the same instance.
The really odd one is arrays, they are ===
if they have the same keys and values defined in the same order.
$a = array("a"=>1, "b"=>2);
$b = array("b"=>2, "a"=>1);
$a == $b; // true
$a === $b; // false
and empty()
is equivalent to !(bool)$var
EXCEPTIONS
Array
__toString
method to a string will get you a fatal error. ArrayAccess
interface)