php.net |  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
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: tomas dot matousek at matfyz dot cz
New email:
PHP Version: OS:

 

 [2004-05-24 11:16 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-28 11:11 UTC] vrana@php.net
This is documentation problem duplicate to #30337 (younger but with more info).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC