Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Passing parameters by their names, like some languages allow.
function _f($callback,$arguments) {
if(!is_callable($callback))throw new Exception('Function '.$callback.' does not exist.');
$params = new ReflectionFunction($callback);
$params = $params->getParameters();
$argNames = array(); foreach ($params as $param){
$argNames[] = $param->name;
foreach($argNames as $name){
else throw new Exception('Not all required parameters passed. '.$key.' is missing');
return call_user_func_array($callback,$argArray);
function test($name,$surname){
echo($name.' '.$surname.'<br/>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment