What is the difference between if($var) and if(isset($var))?
thanks!
J
What is the difference between if($var) and if(isset($var))?
thanks!
J
if($var) will evaluate true if $var is considered BOOLEAN true
if(isset($var)) will evaluate true if $var is set
Then how come the following runs without error?
<?php
$var = 4;
if($var)
{$Return = 'true';}
else
{$Return = 'false';}
echo $Return; // output is 'true'
?>
If $var is not type boolean, does php then try to evaluate an isset($var)?
there is no error because that code is perfectly valid. 4 is an inetger that is not 0 thus it is evulated as TRUE. look at this table to see how various types are evaluated.
thanks! that table is something I had not seen before.