Showing posts with label func_get_args. Show all posts
Showing posts with label func_get_args. Show all posts

Saturday, 6 September 2008

PHP Fatal error: func_get_args(): Can't be used as a function parameter

Well, I was a little surprised about this message but then reading the documentation it all made sense.

The only way around this is to place the result of func_get_args() in a variable and then pass that variable to the function you were calling in the first place instead of func_get_args().

WON'T WORK:

my_func(func_get_args());


WILL WORK:

$func_args=func_get_args();
my_func($func_args);


This is because the func_get_args() function must get called in the right context to return the right values as explained in the PHP documentation (PHP.net func_get_args):

Note: Because this function depends on the current scope to determine parameter details, it cannot be used as a function parameter. If this value must be passed, the results should be assigned to a variable, and that variable should be passed.


Interesting.

Thoughts?
Online Marketing
Add blog to our blog directory blog search directory Blog Directory Blogarama - The Blog Directory