|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-06 14:19 UTC] jorma dot tuomainen at softera dot fi
Description: ------------ Empty() does not return true on empty objects. My understanding is that object that does not have methods or properties is empty(am I wrong?). Someone reported same thing on PHP 5 RC2 and it's still open w/o comments http://bugs.php.net/bug.php?id=28502 Reproduce code: --------------- <?php class nuthin { } $bar=new nuthin; $foo=new stdClass; echo empty($bar); echo empty($foo); ?> Expected result: ---------------- 11 Actual result: -------------- nothing aka empty page PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 15:00:02 2025 UTC |
<?php function empty_object($obj){ return count((array)$obj)==0; } class foo{var $a=1;} $std=new stdclass; $foo=new foo; var_dump(empty_object($obj), empty_object($foo)); ?> bool(true) bool(false)