RE: [PHP-DEV] PHP 4.0 Bug #4865: Problem with != and 0

From: Date: Wed, 07 Jun 2000 12:49:32 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #4865: Problem with != and 0
Groups: php.dev 
Request: Send a blank email to php-dev+get-20459@lists.php.net to get a copy of this message
I belive you should use the !== operator. Using != causes "JBIJI" to be converted to an integer, which is 0 so the result is "is true" and that´s true. regards --marten > -----Original Message----- > From: lwillis@plus.net.uk [mailto:lwillis@plus.net.uk] > Sent: Wednesday, June 07, 2000 2:44 PM > To: php-dev@lists.php.net > Subject: [PHP-DEV] PHP 4.0 Bug #4865: Problem with != and 0 > > > 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??

« previous php.dev (#20459) next »