|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-25 15:47 UTC] tony2001@php.net
[2005-03-20 11:16 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 23:00:01 2025 UTC |
Description: ------------ When I try to count the number of non-static members of an object with the count() function, I always get a count of 1. The code below shows both a user defined class and the standard class(StdClass) instances with more than 1 member variable each but the count() still comes out to 1. Reproduce code: --------------- class jerry{ public $foo='A property'; public $bar='Another property'; } $obj1 = new jerry(); echo $obj1->foo."\n"; echo $obj1->bar."\n"; printf("The count is %d\n",count($obj1)); $obj = new StdClass; $obj->foo='A property'; $obj->bar='Another property'; $obj->bleh='asdf'; echo $obj->foo."\n"; echo $obj->bar."\n"; echo $obj->bleh."\n"; printf("The count is %d\n",count($obj)); Expected result: ---------------- I expect the count() function to count all non-static member variables just like it says in the count() description on php.net Actual result: -------------- The actual count() is 1 for both objects in the code pasted above.