[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SLUG] [Very OT] PHP if statements



>
> For some reason, isset() seems to return the same as if ($variable), which
> will never be true if the $variable == 0.
> 

Not true, That is the purpose of isset()

<?php

$myVar = 0;

if (isset($myVar)) { 
	
	// will execute

}

?>

<?php

if (isset($myVar)) {
	
	// $myVar has never been set
	// will not execute

}

?>

<?php

$myVar = 0; // zero means FALSE, any other value is good (positive or
negative)


if ($myVar) {

	// $myVar is considered set by isset
	// however it evaluates to zero,
	// and will therefore not execute

}

?>


--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug