1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <?php
namespace _1008;
function sum($a, $b) { return "{$a} + {$b} = " . ($a + $b); }
class Test { public function reduce($a, $b) { return "{$a} - {$b} = " . ($a - $b); }
public static function multiply($a, $b) { return "{$a} x {$b} = " . ($a * $b); } }
echo call_user_func(__NAMESPACE__ . '\sum', 11, 22); echo "<hr>";
echo call_user_func_array(__NAMESPACE__ . '\sum', [1, 2]); echo "<hr>";
echo call_user_func_array([new Test(), 'reduce'], [22, 11]); echo "<hr>";
echo call_user_func_array(__NAMESPACE__ . '\Test::multiply', [11, 11]); echo "<br>";
echo call_user_func_array([Test::class, 'multiply'], [11, 12]); echo "<hr>"; ?>
|