views:

25

answers:

1

This is what I got so far;

<?php ReflectionFunction::export(new ReflectionFunction(filter_input()));

And I get this error: Warning: filter_input() expects at least 2 parameters, 0 given in C:\wamp\www\POS\Ch4\inspect_filter_input_function.php on line 2

If I get rid of the parentheses, I get a warning but I the function's info. If I put two undefined variables it complains and I get nothing. I was wondering if I can get an example how to reflect functions with parameters.

Thank you in advance.

+1  A: 

ReflectionFunction::export() expects a string (name of the function) as the first parameter, not a ReflectionFunction object:

ReflectionFunction::export('filter_input');
/* Output:
Function [ <internal:filter> function filter_input ] {
}
*/

or

$ouput = ReflectionFunction::export('filter_input', true);

An alternative is to directly print the ReflectionFunction object, since it implements the magic method __toString():

echo new ReflectionFunction('filter_input');
/* Output:
Function [ <internal:filter> function filter_input ] {
}
*/
nuqqsa