Name of function arguments
Name of function arguments
am 25.01.2008 15:08:52 von turnitup
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"
Re: Name of function arguments
am 25.01.2008 15:32:43 von zeldorblat
On Jan 25, 9:08 am, turnitup 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"
No easy way -- but I'm curious why you need them. Care to share?
Re: Name of function arguments
am 25.01.2008 15:42:16 von luiheidsgoeroe
On Fri, 25 Jan 2008 15:08:52 +0100, turnitup 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"
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
Re: Name of function arguments
am 25.01.2008 15:54:21 von ivansanchez-alg
turnitup wrote:
> What's the easiest way to get the name of function arguments?
Reflection.
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Re: Name of function arguments
am 25.01.2008 19:55:43 von Michael Fesser
..oO(turnitup)
>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"
Why?
Micha