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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to