php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16955 0 == NULL, but only sometimes! :)
Submitted: 2002-05-01 17:20 UTC Modified: 2002-05-02 01:59 UTC
From: claudio dot frizziero at nereal dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.0 OS: Red Hat 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: claudio dot frizziero at nereal dot com
New email:
PHP Version: OS:

 

 [2002-05-01 17:20 UTC] claudio dot frizziero at nereal dot com
Hello!
i might have found a problem dealing with 0 and NULL values while using a recursive function in a class that i have created.

I have found some bugs related to this problem in the php-bugs database about "0" and "NULL", but the problem i have found goes more into depth: i've noticed that 0 == NULL only if the value "0" only if the value "0" comes from the array passed to the recurvise function. i try to explain with an example:

$temp = $a[$p];

if ($temp == "") {
 if ($temp == "0") {
  echo ("impossible");
 }
}

it happens that the output will be "impossible".

instead, if i set $temp = "0" or NULL before the IF structures, i won't get the output "impossible":

$temp = $a[$p];

$temp = "0";
   // or  $temp = NULL;
   // or without declaring at all the variable $temp

if ($temp == "") {
 if ($temp == "0") {
  echo ("Impossible");
 }
}



$a is an array which can be modified or not by the recursive function, and is then passed as a parameter to the function itself

I have tested it both with version 4.0.5 and 4.2.0

If you would like to receive more details about this, i will be glad to send you the complete source code. i have tried to reduce the lenght of the code, anyway it's still too long to write here. if you are interested, i could send you all the code by email or i could give you an account to access my server and work by ftp/http

best regards,
and thank you for developing PHP :)
Claudo Frizziero

---

configure line:

configure --with-mysql --with-apxs=/usr/local/apache/bin/apxs --with-jpeg-dir=/usr/local/bin --with-gd=/usr/ --enable-ftp

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-01 19:14 UTC] claudio dot frizziero at nereal dot com
I find the problem:

$temp = "0"; // is not // $temp = 0;

Sorry :)

However, I'd like to have 0 <> NULL in the future :) Don't you think?
 [2002-05-02 01:59 UTC] derick@php.net
Already exists, try if (NULL !== 0) { ... } else { ... }

bogussing.

Derick
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 16:02:26 2025 UTC