When you use logical operators, operands (the value on the left and the value on the right) are evaluated as logical, so basically this code will do it shorter:
$o1 = (Bool)$data; // cast to bool if($o1) $o2 = (Bool)$this->template->set_global($data); // cast to bool
Edit:
Additional Information:
$a = 33; isset($a) && print($a) || print("not set"); echo "<br>"; isset($a) AND print($a) OR print("not set"); echo "<br>";
Try to comment / expand $a = 33;
. This is the difference between &&
and AND
, and between ||
and OR
( print
returns true, which is passed to "1" when converting to a string).
user652649
source share