RE: [PHP] If statement being ignored by PHP

From: Date: Fri, 30 Jun 2000 14:39:03 +0000
Subject: RE: [PHP] If statement being ignored by PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4037@lists.php.net to get a copy of this message
> if ($post="yes"): > > mail("$recipient <$remail>", "$sender has sent you a card", > $message,"From: $semail \nReply-To: $semail\nX-Mailer: PHP3"); > echo "Your card number $idnumber has been sent to $recipient."; > endif; > > endif; > PHP is a bastard - this is one problem which gets everyone at one point. For if statements, the operator is == to check if it is equal to - not just a single = sign. This is due to the fact that PHP will parse that statement even in an if statement [i.e. set $post="yes", not work out whether it equals yes.] Hope that helps - but if it doesn't make any sense just remember: if ($post=="yes") { blah; } NOT if ($post="yes") { blah; } Regards, Emile Axelrad

« previous php.general (#4037) next »