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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
30 + 10 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Fri Jul 23 17:01:23 2021 UTC