fork(1) download
  1. <?php
  2.  
  3. function apply_first_argument($callback, $arg) {
  4. return function()use($arg, $callback) {
  5. $other_args = func_get_args();
  6. array_unshift($other_args, $arg);
  7. return call_user_func_array($callback, $other_args);
  8. };
  9. }
  10.  
  11. function apply_last_argument($callback, $arg) {
  12. return function()use($arg, $callback) {
  13. $other_args = func_get_args();
  14. array_push($other_args, $arg);
  15. return call_user_func_array($callback, $other_args);
  16. };
  17. }
  18.  
  19. $pow2_ = apply_first_argument(pow, 2);
  20. $pow_2 = apply_last_argument(pow, 2);
  21. echo '2 ^ 3 = ' . $pow2_(3) . PHP_EOL;
  22. echo '3 ^ 2 = ' . $pow_2(3) . PHP_EOL;
Success #stdin #stdout #stderr 0.01s 82560KB
stdin
Standard input is empty
stdout
2 ^ 3 = 8
3 ^ 2 = 9
stderr
PHP Notice:  Use of undefined constant pow - assumed 'pow' in /home/w3zTWJ/prog.php on line 19
PHP Notice:  Use of undefined constant pow - assumed 'pow' in /home/w3zTWJ/prog.php on line 20