Skip to content

Instantly share code, notes, and snippets.

@slifin
Created June 17, 2015 08:12
Show Gist options
  • Save slifin/737926dfa682367c0600 to your computer and use it in GitHub Desktop.
Save slifin/737926dfa682367c0600 to your computer and use it in GitHub Desktop.
<?php
function partial_function() {
$applied_args = func_get_args();
return function() use($applied_args) {
return call_user_func_array('call_user_func', array_merge($applied_args, func_get_args()));
};
}
function foo($a, $b, $c) {
echo "a: {$a} b: {$b} c: {$c}\n";
}
$foo_caller = partial_function('foo', 'A');
$foo_caller('B');
$foo_caller('C');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment