This is a discussion on Using ReflectionParameter in PHP5 within the PHP Language forums, part of the PHP Programming Forums category; Hello! I want to get the parameters of an internal php function and have tried to use the new reflection ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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! |
|
|||
|
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 |
|
|||
|
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. |