#28502 [Opn->Bgs]: empty statement misbehaves on objects

From: Date: Thu, 28 Oct 2004 09:11:22 +0000
Subject: #28502 [Opn->Bgs]: empty statement misbehaves on objects
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969364695@lists.php.net to get a copy of this message
ID: 28502 Updated by: vrana@php.net Reported By: tomas dot matousek at matfyz dot cz -Status: Open +Status: Bogus -Bug Type: Zend Engine 2 problem +Bug Type: Documentation problem Operating System: WinXP PHP Version: 5.0.0RC2 New Comment: This is documentation problem duplicate to #30337 (younger but with more info). Previous Comments: ------------------------------------------------------------------------ [2004-05-24 11:16:12] tomas dot matousek at matfyz dot cz Description: ------------ There is written in the manual that empty($object) == TRUE, where $object has empty properties. >> empty() returns FALSE if var has a non-empty or non-zero value. In otherwords, "", 0, "0", NULL, FALSE, array(), var $var;, and objects with empty properties, are all considered empty. TRUE is returned if var is empty. << But IMHO there is an error if $object is instance of class A {}. I think the A's instance has no properties hence it is an "object with empty properties". So why empty($a) == FALSE where $a = new A? It seems that empty() does never return TRUE. BTW: What does "var $var;" mean? Reproduce code: --------------- class A {} $a = new A; var_dump(empty($a)); Expected result: ---------------- bool(true) Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28502&edit=1

« previous php.doc (#969364695) next »