6 $g = function($a = 'default') {
7 echo "in \$g; passed $a\n";
10 /** This doc comment is so helpful and descriptive. */
11 $add = function($x, $y) {
13 echo 'x + y = ' . $sum . "\n";
16 function show_params($params) {
17 echo 'parameters => array(' . count($params) . ") {\n";
18 foreach ($params as $p) {
19 echo " name => {$p->getName()}\n";
24 var_dump($rf->getName());
25 var_dump($rf->isUserDefined());
26 var_dump($rf->getStartLine());
27 var_dump($rf->getEndLine());
28 var_dump($rf->getDocComment());
29 var_dump($rf->getFileName() === __FILE__
);
30 show_params($rf->getParameters());
31 var_dump($rf->getNumberOfParameters());
32 var_dump($rf->getNumberOfRequiredParameters());
35 $rf = new ReflectionFunction($f);
36 $rg = new ReflectionFunction($g);
37 $radd = new ReflectionFunction($add);
42 echo "\ninvoking g\n";
44 $rg->invokeArgs(array('goodbye'));
46 echo "\ninvoking add\n";
48 $radd->invokeArgs(array(5000000000, 5000000000));
56 echo "\nshowing add\n";