RE: [PHP-DEV] PHP 4.0 Bug #6738: If statement not liking 0
| From: | Craig Vincent | Date: | Thu, 14 Sep 2000 14:44:59 +0000 |
| Subject: | RE: [PHP-DEV] PHP 4.0 Bug #6738: If statement not liking 0 | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-33248@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) { }
I don't think this is a bug
if ($testvar = 0) { }
would always evaluate true because the syntax is incorrect
if ($testvar == 0) { }
is the correct IF statement to use.
Sincerely,
Craig Vincent
-------------------------
Senior Programmer
Jazzmonkey Media Inc.
http://www.jazzmonkey.com
-------------------------