Page 2 of 2

Re: Variable scope

Posted: Wed May 19, 2010 2:50 pm
by John Cartwright
AbraCadaver wrote:
larrygingras wrote:Unfortunately, no. It seems that it is not permitted to use function for default argument value: PHP Parse error: syntax error, unexpected '(', expecting ')' in /cd/home/admin/test.php on line 2
You can do this, however I would recommend one of the other solutions:

Code: Select all

safe_query('query', get_defined_vars());
If the variables are global, then you can just use the $GLOBALS array in the safe_query() function.
I agree. This will only lead to difficult bugs and maintenance nightmares. You should only pass exactly and explicitly what the function needs to process.