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

From: Date: Wed, 13 Sep 2000 21:00:38 +0000
Subject: PHP 4.0 Bug #6738 Updated: If statement not liking 0
Groups: php.dev 
Request: Send a blank email to php-dev+get-33226@lists.php.net to get a copy of this message
ID: 6738 Updated by: sniper Reported By: coolfr3ak@hotmail.com Status: Closed Bug Type: *General Issues Assigned To: Comments: More info can be found here: http://www.php.net/manual/language.operators.comparison.php --Jani Previous Comments: --------------------------------------------------------------------------- [2000-09-13 16:57:59] eriksson@php.net This is not a bug in PHP You should use '==' when you compare values. I cannot reproduce a crash in PHP when assigning 0 to 0. -- David Eriksson -/- --------------------------------------------------------------------------- [2000-09-13 16:32:42] coolfr3ak@hotmail.com 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 --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6738

« previous php.dev (#33226) next »