...

View Full Version : IF Statement Evaluates TRUE always



macleodjb
05-17-2008, 07:08 PM
Hi guys, what is causing this statement to eval to true all the time?



<?php if ($_SERVER['PHP_SELF'] = "help.php") { echo "help_on.jpg"; } else { echo "help_off.jpg"; } ?>

CFMaBiSmAd
05-17-2008, 07:25 PM
= is an assignment operator
== is an equal comparison operator

$_SERVER['PHP_SELF'] = "help.php" sets $_SERVER['PHP_SELF'] equal to "help.php" and since the result of that is not false, the if() statement evaluates to TRUE.

runnerjp
05-17-2008, 07:26 PM
<?php if ($_SERVER['PHP_SELF'] == "help.php") { echo "help_on.jpg"; } else { echo "help_off.jpg"; } ?>


woops allready done



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum