Jump to content

php function argument "variable name"


NeoMarine

Recommended Posts

I'm trying to loop through all the arguments passed into the function:

 

foreach (get_func_arg() as $variableName => $variableValue){

 

    $argumentsPassed .= $variableName."=".$variableValue.", ";

 

}

 

return $argumentsPassed;

So, if I entered something like:

 

$variable1="Cool";

$coolStuff="1234";

echo myFunction($variable1, $coolStuff);

 

The output will be:

 

$variable1=Cool, $coolStuff="1234" (or without the $'s)

 

ANY IDEAS?? Is it even possible?? I need this because my variable names are required, and their could be any number of function arguments(variables) passed

Link to comment
https://forums.phpfreaks.com/topic/133721-php-function-argument-variable-name/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.