ThePsion5 Posted March 3, 2006 Share Posted March 3, 2006 Hi,Say I create two global variables, one of which contains the other like so: $var = "your name";$var2 = "My god, $var is teh best PHP coder evuh!!!!!11111"; and I call $var2 inside of a function like so: function tellTheWorld() {global $var2echo $var2; } or function tellTheWorld() {$var = "someone other than you";global $var2echo $var2; } what exactly will be echoed? In technical terms, if I access a global variable that references another variable, does it reference it in the scope of the function or at the global level? Link to comment Share on other sites More sharing options...
aspnetguy Posted March 3, 2006 Share Posted March 3, 2006 You raise a good question. I am not 100% sure how PHP does it but in JavaScript if you declare a global variable and then change the value within a function the new value now becomes the global value so anytime the global variable is called (in or outside of a function) the value is whatever the last process set it to not necessarily the original value.Hope that helps...give it a test and see if PHP works the same way...I suspect that it does. 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