#20932 [Opn->Bgs]: Class without member variables gives "empty"/"null" objects
| From: | sniper@php.net | Date: | Wed, 11 Dec 2002 12:05:15 +0000 |
| Subject: | #20932 [Opn->Bgs]: Class without member variables gives "empty"/"null" objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27336@lists.php.net to get a copy of this message | ||
ID: 20932
Updated by: sniper@php.net
Reported By: richter@cyperfection.de
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 4.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2002-12-11 04:47:43] richter@cyperfection.de
take the following example:
<?php
class MethodsOnly {
//var $dummy;
function doSomething() {
print("OBJ: doing something\n");
}
}// class
$OBJ = new MethodsOnly();
$OBJ->doSomething();
print("empty(OBJ): ".(empty($OBJ) ? "true" :
"false")."\n");
print("OBJ == null: ".(($OBJ == null) ? "true" :
"false")."\n");
print("OBJ === null: ".(($OBJ === null) ? "true" :
"false")."\n");
?>
it gives the following output:
OBJ: doing something
empty(OBJ): true
OBJ == null: true
OBJ === null: false
now, if you uncomment the $dummy member variable:
OBJ: doing something
empty(OBJ): false
OBJ == null: false
OBJ === null: false
Sure, one should/could use "static calls" - like
MethodsOnly::doSomething() - in this case (class without member vars),
but we discovered this when migrating a project from PHP3 to PHP4
.. and, anyway, shouldn't an existing object behave the same wether it
has member variables or not? ;)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20932&edit=1