Re: IF command

From: Date: Fri, 19 Oct 2007 17:33:54 +0000
Subject: Re: IF command
Groups: php.general 
Request: Send a blank email to php-general+get-263404@lists.php.net to get a copy of this message
On Oct 18, 2007, at 9:50 PM, Bastien Koert wrote:
Are you sure that the value is a string? If its numeric, then try the check without the quotes around the value
http://www.php.net/manual/en/language.operators.comparison.php "If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers." <?php $component_reference = 5; if ( ($component_reference != "5") AND ($component_reference != "19") ) { echo("I am not a 5 or a 19<br>"); } else echo("I am a 5 or a 19<br>"); $component_reference = "5"; if ( ($component_reference != "5") AND ($component_reference != "19") ) { echo("I am not a 5 or a 19<br>"); } else echo("I am a 5 or a 19<br>"); $component_reference = 3; if ( ($component_reference != "5") AND ($component_reference != "19") ) { echo("I am not a 5 or a 19<br>"); } else echo("I am a 5 or a 19<br>"); $component_reference = "3"; if ( ($component_reference != "5") AND ($component_reference != "19") ) { echo("I am not a 5 or a 19<br>"); } else echo("I am a 5 or a 19<br>"); ?> The results: I am a 5 or a 19 I am a 5 or a 19 I am not a 5 or a 19 I am not a 5 or a 19

« previous php.general (#263404) next »