Using ReflectionParameter in PHP5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I want to get the parameters of an internal php function and have tried
to use the new reflection classes introduced in PHP5. This is what I've


$funcArr = get_defined_functions();

echo $funcArr["internal"][5] . "\r";

$ref = new ReflectionFunction($funcArr["internal"][5]);

echo $ref;

foreach ($ref->getParameters() as $i => $param)
printf("-- Parameter #%d: %s \n" $i, $param->getName());


this outputs:

strcmp Function [  public function strcmp ] { }

that output is only done by the two echo:s. There is nothing outputed
by the foreach loop.

Thanks in advance!

Re: Using ReflectionParameter in PHP5

Lucius wrote:
Quoted text here. Click to load it
Quoted text here. Click to load it

I don't think you can reverse-engineer native functions with the
ReflectionFunction class, only user-defined:

function foo($name, $bla) {}

$ref = new ReflectionFunction("foo");

foreach ($ref->getParameters() as $i => $param) {
     printf("-- Parameter #%d: %s \n", $i, $param->getName());


Re: Using ReflectionParameter in PHP5


That's sad =( I though you could because in the PHP5 Power Programming
book they do: ReflectionClass::export("ReflectionParameter");

I am working on a simple phpeditor know of any other way to
automatically get information (name, returntype, description,
parametersname and returntype)? I am going to add it to an XML file. I
guess I'll have to do it by hand then.

Re: Using ReflectionParameter in PHP5

use the documentation on getting the .html files from there or
something should be the second easiest way I suppose.

Site Timeline