Francis_and_Hobbel Posted March 1 Share Posted March 1 I have a website in which a function is called hundreds of times. There is a variable in the main program that I need within the function, but it's not there. I could add another argument containing that variable function_name($a,$b,$required_variable); instead of function_name($a,$b); but then the program would become a lot bigger! So is there a method that doesn't require so much extra data? Link to comment Share on other sites More sharing options...
Ingolme Posted March 1 Share Posted March 1 An easy patch is to use the global keyword, but usually this kind of situation indicates a fundamental problem with your software's design and it might be worth redesigning your software to make future maintenance easier. Link to comment Share on other sites More sharing options...
Francis_and_Hobbel Posted March 1 Author Share Posted March 1 5 hours ago, Ingolme said: An easy patch is to use the global keyword, but usually this kind of situation indicates a fundamental problem with your software's design and it might be worth redesigning your software to make future maintenance easier. I tried global and ik works. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now