Re: PHP 4.0 Bug #6738: If statement not liking 0

From: Date: Thu, 14 Sep 2000 09:35:41 +0000
Subject: Re: PHP 4.0 Bug #6738: If statement not liking 0
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-33227@lists.php.net to get a copy of this message
I was talking this over with joey smith on IRC (Efnet/#php) I think this pretty much explains: [msg(TML)] define ("NULL_CONSTANT", 0); [msg(TML)] print (0 == NULL_CONSTANT) ? "0=0" : "0 != 0?!?!?!?"; [msg(TML)] returns 0=0 [msg(TML)] if (0 = NULL_CONSTANT) { } [msg(TML)] thats what the guy got. [msg(TML)] if ($testvar = 0) { } would evaluate to $testvar being 0, being false. [msg(TML)] what he's doing is an assignment [msg(TML)] basically its this: [msg(TML)] $testvar = 0; [msg(TML)] if ($testvar) { } On 13 Sep 2000 coolfr3ak@hotmail.com wrote: > From: coolfr3ak@hotmail.com > Operating system: Linux 6.1 > PHP version: 4.0.2 > PHP Bug Type: *General Issues > Bug description: If statement not liking 0 > > if i have > > define("_DEFINED_CONSTANT", 0) > > function xyz ($committype = _DEFINED_CONSTANT) > { > if ($committype = _DEFINED_CONSTANT) > { > ...do stuff... > } > } > > then the if statement fails to recognise that when a 0 = 0, the statement should be true, > instead it returns zero, which is rather anoying... > > Its a pretty obvious problem - you can try it yourself just put > > $pug = 0 > if ($pug = 0) > { echo "foo"; } > > an it won't recognise it... > (it crashes if you ask it for 'if (0 = 0) {...}' for some reason - perhaps another > bug? > > IcK > > > > -- > 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 >

« previous php.dev (#33227) next »