Advertisement

06.20.2008 at 09:58AM PDT, ID: 23502917
[x]
Attachment Details

What are the best ways to avoid using globals?

Asked by locke2005 in PHP Scripting Language

What if you create a function that uses 3 parameters, then you call this function 3 times in 3 different php files in 3 different directories, then you had to modify the function to use 6 parameters, but changing the order of the 3 old parameters with the 3 new parameters?

Everytime you add a parameter to function, you will have to search and replace with regular expression in multiple directories to change the calls to the function. That is really complicated! I do not want to add a  security risk to my site. What are the best ways to avoid using globals?

By the way, if I pass 10 variables to a function, then change the 10 variables, then return 10 variables, then call the function, will I already be able to use the variables out of the function or will I yet have to assign the returned 10 variables to 10 variables?Start Free Trial
[+][-]06.20.2008 at 10:01AM PDT, ID: 21833003

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.20.2008 at 10:01AM PDT, ID: 21833004

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Sign Up Now!
Solution Provided By: Roonaan
Participating Experts: 4
Solution Grade: A
 
 
[+][-]06.20.2008 at 10:27AM PDT, ID: 21833189

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.20.2008 at 10:31AM PDT, ID: 21833219

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628