Variable scope

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Variable scope

Post 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.
Post Reply