To obtain the value of the arguments of the function
-
Used in the templates where I need to connect the Pope as a marker to the function:
Main_Registry::setVar('disclaimer', true);
In the first specimen, I want to determine which text for the cap is to be removed from the base. How do I get the first argument from another method without changing the function setVar without adding it?
func_get_args()
?I've been through this.
reflection - new ReflectionParameter(array('Main_Registry', 'setVar'), 0);
- but it reverts to the argument, not the point of argument in challenging the function.
-
Dry the parameters. Here's the option:
class Main_Registry {
public static function setVar($param , $bool = true){ if($bool){ return self::getResult($param); } } private static function getResult($param){ $data = [ 'disclaimer' => "value 1", 'main' => "value 2", 'common' => "value 3", ]; return ($data[$param] ? $data[$param] : "param {$param} not exist"); }
}
echo(Main_Registry::setVar('disclaimer', true)."\n");
echo(Main_Registry::setVar('main', true)."\n");
echo(Main_Registry::setVar('empty', true)."\n");
value 1 value 2 param empty not exist