note 118215 added to reflectionfunctionabstract.getparameters

From: Date: Tue, 27 Oct 2015 13:33:32 +0000
Subject: note 118215 added to reflectionfunctionabstract.getparameters
Groups: php.notes 
Request: Send a blank email to php-notes+get-204039@lists.php.net to get a copy of this message
This is part of my private framework that uses reflection. This function get arguments list from theme method and puts corresponding vars from $_REQUEST ($_GET, $_POST, and $_COOKIE) <?php public static function fire_theme_method($class, $method) { $fire_args=array(); $reflection = new ReflectionMethod($class, $method); foreach($reflection->getParameters() AS $arg) { if($_REQUEST[$arg->name]) $fire_args[$arg->name]=$_REQUEST[$arg->name]; else $fire_args[$arg->name]=null; } return call_user_func_array(array($class, $method), $fire_args); } ?> For example, if my theme method needs only id, and we get this url: http://example.com/my_class/my_method/?id=12&some_unwanted_var=123 will be ignored some_unwanted_var Of course behind this i have .htaccess, autoloader and controller ---- Server IP: 72.52.91.14 Probable Submitter: 213.241.20.254 ---- Manual Page -- http://php.net/manual/en/reflectionfunctionabstract.getparameters.php Edit -- https://master.php.net/note/edit/118215 Del: integrated -- https://master.php.net/note/delete/118215/integrated Del: useless -- https://master.php.net/note/delete/118215/useless Del: bad code -- https://master.php.net/note/delete/118215/bad+code Del: spam -- https://master.php.net/note/delete/118215/spam Del: non-english -- https://master.php.net/note/delete/118215/non-english Del: in docs -- https://master.php.net/note/delete/118215/in+docs Del: other reasons-- https://master.php.net/note/delete/118215 Reject -- https://master.php.net/note/reject/118215 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204039) next »