Name of function arguments

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"
turnitup [ Fr, 25 Januar 2008 15:08 ] [ ID #1916390 ]

Re: Name of function arguments

On Jan 25, 9:08 am, turnitup <same [at] 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"

No easy way -- but I'm curious why you need them. Care to share?
zeldorblat [ Fr, 25 Januar 2008 15:32 ] [ ID #1916392 ]

Re: Name of function arguments

On Fri, 25 Jan 2008 15:08:52 +0100, turnitup <same [at] 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
luiheidsgoeroe [ Fr, 25 Januar 2008 15:42 ] [ ID #1916394 ]

Re: Name of function arguments

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.
ivansanchez-alg [ Fr, 25 Januar 2008 15:54 ] [ ID #1916396 ]

Re: Name of function arguments

..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
Michael Fesser [ Fr, 25 Januar 2008 19:55 ] [ ID #1916400 ]
PHP » comp.lang.php » Name of function arguments

Vorheriges Thema: MySQL design question
Nächstes Thema: Contact Form Spam