|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #28502 empty statement misbehaves on objects
Submitted: 2004-05-24 11:16 UTC Modified: 2004-10-28 11:11 UTC
From: tomas dot matousek at matfyz dot cz Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.0.0RC2 OS: WinXP
Private report: No CVE-ID: None
 [2004-05-24 11:16 UTC] tomas dot matousek at matfyz dot cz
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;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-28 11:11 UTC]
This is documentation problem duplicate to #30337 (younger but with more info).
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 11:03:37 2021 UTC