By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

Using ReflectionParameter in PHP5

P: n/a
Hello!

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
done:

<?php

$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!

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Lucius wrote:
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 done: [...] 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.


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());
}
JW

Jul 17 '05 #2

P: n/a
Hello!

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.

Jul 17 '05 #3

P: n/a
use the documentation on php.net? getting the .html files from there or
something should be the second easiest way I suppose.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.