note 108846 added to function.get-object-vars
| From: | FabienHaddadi | Date: | Wed, 30 May 2012 09:42:34 +0000 |
| Subject: | note 108846 added to function.get-object-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188288@lists.php.net to get a copy of this message | ||
It seems like there's no function that determines all the *static* variables of a class.
I've come out with this one as I needed it in a project:
function get_class_static_vars($object) {
return array_diff(get_class_vars(get_class($object)), get_object_vars($object));
}
It relies on an interesting property: the fact that get_object_vars only returns the non-static
variables of an object.
----
Server IP: 69.147.83.197
Probable Submitter: 182.239.160.10
----
Manual Page -- http://www.php.net/manual/en/function.get-object-vars.php
Edit -- https://master.php.net/note/edit/108846
Del: integrated -- https://master.php.net/note/delete/108846/integrated
Del: useless -- https://master.php.net/note/delete/108846/useless
Del: bad code -- https://master.php.net/note/delete/108846/bad+code
Del: spam -- https://master.php.net/note/delete/108846/spam
Del: non-english -- https://master.php.net/note/delete/108846/non-english
Del: in docs -- https://master.php.net/note/delete/108846/in+docs
Del: other reasons-- https://master.php.net/note/delete/108846
Reject -- https://master.php.net/note/reject/108846
Search -- https://master.php.net/manage/user-notes.php