- var_dump: documentation ( source)
- array_shift: documentation ( source)
<?php
function bind($cb) {
$bound_args = func_get_args();
array_shift($bound_args);
$bound_exec = function () use ($bound_args, $cb) {
$args = $bound_args + func_get_args();
var_dump($args);
call_user_func_array($cb, $args);
};
return $bound_exec;
}
$fn = bind(function ($a, $b) { return $a . $b; }, 'hello ');
echo $fn('world');