|
Posted by Rik Wasmus on 01/25/08 14:42
On Fri, 25 Jan 2008 15:08:52 +0100, turnitup <same@same> wrote:
> What's the easiest way to get the name of function arguments?
>
> For example
>
> function fred($day, $week)
> {
> echo (firstargumentname);
> echo (secondargumentname);
>
> }
>
> echoes "day" "week"
<?php
function foo($foo,$bar){
$func =3D new ReflectionFunction(__FUNCTION__);
$params =3D $func->getParameters();
foreach($params as $number =3D> $param){
print("Argument #{$number} is called {$param->name}.\n");
}
}
foo(1,2);
?>
However, this is not really something for production, but rather for =
inspection of 'unknown' code.
-- =
Rik Wasmus
[Back to original message]
|