note 98394 added to function.get-object-vars

From: Date: Sat, 12 Jun 2010 12:56:21 +0000
Subject: note 98394 added to function.get-object-vars
Groups: php.notes 
Request: Send a blank email to php-notes+get-170082@lists.php.net to get a copy of this message
Here is a function for getting only public properties even if you are in the class: <?php function my_get_object_vars($obj) { $ref = new ReflectionObject($obj); $pros = $ref->getProperties(ReflectionProperty::IS_PUBLIC); $result = array(); foreach ($pros as $pro) { false && $pro = new ReflectionProperty(); $result[$pro->getName()] = $pro->getValue($obj); } return $result; } ?> ---- Server IP: 222.73.207.145 Probable Submitter: 127.0.0.1 (proxied: 218.5.2.219) ---- Manual Page -- http://www.php.net/manual/en/function.get-object-vars.php Edit -- https://master.php.net/note/edit/98394 Del: integrated -- https://master.php.net/note/delete/98394/integrated Del: useless -- https://master.php.net/note/delete/98394/useless Del: bad code -- https://master.php.net/note/delete/98394/bad+code Del: spam -- https://master.php.net/note/delete/98394/spam Del: non-english -- https://master.php.net/note/delete/98394/non-english Del: in docs -- https://master.php.net/note/delete/98394/in+docs Del: other reasons-- https://master.php.net/note/delete/98394 Reject -- https://master.php.net/note/reject/98394 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170082) next »