Variable recognition
Posted: Thu Apr 28, 2005 11:35 am
Hi
I can't work out what is causing this strange problem with PHP 'incorrectly' determining the contents of a variable. In the run whos output I quote, $type = 0. However, PHP doesn't seem to recognise this. Here is the code:
and here is the output, directly cut and pasted:
Incidently, if I change the check for 'ALL_TYPES' to 'ABSOLUTE_GIMBOID' for example, I get exactly the same problem - it then seems to think that 0 == 'ABSOLUTE_GIMBOID'.
Can anyone shed any light on this problem? Why is it thinking that 0 is equal to any string I place in the if statement?
Many thanks
Mark
I can't work out what is causing this strange problem with PHP 'incorrectly' determining the contents of a variable. In the run whos output I quote, $type = 0. However, PHP doesn't seem to recognise this. Here is the code:
Code: Select all
if( $page == 1 )
{
if( $loc == 'ALL_LOCS' )
{
if( $type == 'ALL_TYPES' )
{
echo 'PHP thinks that '.$type.' == ALL_TYPES!!';
}
elseif( $type != 'ALL_TYPES' )
{Code: Select all
PHP thinks that 0 == ALL_TYPES!!Can anyone shed any light on this problem? Why is it thinking that 0 is equal to any string I place in the if statement?
Many thanks
Mark