Re: PHP 4.0 Bug #4865: Problem with != and 0

From: Date: Wed, 07 Jun 2000 17:18:42 +0000
Subject: Re: PHP 4.0 Bug #4865: Problem with != and 0
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-20482@lists.php.net to get a copy of this message
It shoul be definitely documented, that with ($tmp != $string) one has to be careful comparing [integers] against [numbers] if ($tmp>0 OR $tmp<0) the above will work, $tmp!=$string -> TRUE if $tmp=0 it won´t work, because in fact the script compared $tmp against (int)$string==0 This is a potentially pit newbies will fall into and I suppose it to be documented, perhaps a small page about automatic conversion including the use of !== and === would be fine... regards
From:             lwillis@plus.net.uk
Operating system: Linux 2.2.14
PHP version:      4.0.0 Release
PHP Bug Type:     Other
Bug description: Problem with != and 0 The following script produces unexpected results: <? $tmp = 0; if ($tmp != "JBIJI") {
    echo "is true";
} else {
    echo "is false";
} ?> This produces "is false" as output where I would have thought that since the value of $tmp isn't "JBIJI" the expression "$tmp != 'JBIJI'" should evaluate true?? -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
o----------0-¬---------O-·---¬----o---®-----o o    O   °       .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0  O °     ¤  °        ·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . ·
| psychedelic experience |  gott@kiffen.de  | O   ° o           °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·

« previous php.dev (#20482) next »