php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6738 If statement not liking 0
Submitted: 2000-09-13 16:32 UTC Modified: 2000-09-13 17:00 UTC
From: coolfr3ak at hotmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.2 OS: Linux 6.1
Private report: No CVE-ID: None
 [2000-09-13 16:32 UTC] coolfr3ak at hotmail dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-13 16:57 UTC] 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 17:00 UTC] sniper@php.net
More info can be found here:

http://www.php.net/manual/language.operators.comparison.php

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC