note 105404 added to reserved.classes

From: Date: Mon, 15 Aug 2011 21:21:21 +0000
Subject: note 105404 added to reserved.classes
Groups: php.notes 
Request: Send a blank email to php-notes+get-182497@lists.php.net to get a copy of this message
if you want a Dynamic class you can extend from, add atributes AND methods on the fly you can use this: <?php class Dynamic extends stdClass{ public function __call($key,$params){ if(!isset($this->{$key})) throw new Exception("Call to undefined method ".get_class($this)."::".$key."()"); $subject = $this->{$key}; call_user_func_array($subject,$params); } } ?> this will accept both arrays, strings and Closures: <?php $dynamic->myMethod = "thatFunction"; $dynamic->hisMethod = array($instance,"aMethod"); $dynamic->newMethod = array(SomeClass,"staticMethod"); $dynamic->anotherMethod = function(){ echo "Hey there"; }; ?> then call them away =D ---- Server IP: 69.147.83.197 Probable Submitter: 187.55.215.170 ---- Manual Page -- http://www.php.net/manual/en/reserved.classes.php Edit -- https://master.php.net/note/edit/105404 Del: integrated -- https://master.php.net/note/delete/105404/integrated Del: useless -- https://master.php.net/note/delete/105404/useless Del: bad code -- https://master.php.net/note/delete/105404/bad+code Del: spam -- https://master.php.net/note/delete/105404/spam Del: non-english -- https://master.php.net/note/delete/105404/non-english Del: in docs -- https://master.php.net/note/delete/105404/in+docs Del: other reasons-- https://master.php.net/note/delete/105404 Reject -- https://master.php.net/note/reject/105404 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182497) next »