How can I use the local variable $ y in row 19th in the global environment? is there any way to use the local variable in row 5th globally? the reason for this is that I started to learn PHP wants to know if there is such a method. thank you.
How can I use local variables in the global environment?
$ Y in row 19th is undefined. Is there any way to use local variables in row 5th globally?
The reason for this question is that I started learning PHP and want to know if there is such a method. thank you.
Reply content:
How can I use local variables in the global environment?
$ Y in row 19th is undefined. Is there any way to use local variables in row 5th globally?
The reason for this question is that I started learning PHP and want to know if there is such a method. thank you.
Global $ y;
$ Y = 10;
Global $ adfds = & y;
You can try this one, I don't know;
Either of the two methods is to add the global keyword, global $ y; $ y = 10; the second is to put it in the ultra-global Array $ GLOBALS, for example, $ GLOBALS ['Y'] = 10
If you have a global variable $ a first, then reference it in a local scope, and declare it with the global keyword.
(If $ a is used in the function, a local $ a is created by default instead of a global one ).
This is the official global page: (we suggest you read the official manual first when you encounter any problems)
Http://www.php.net/manual/zh/language.va...
But your question is, how does one change the local variable $ y in the function into a global one?
The answer is, there is no way .... Php does not have this function... ===
Don't worry, you don't need to do that. It is rarely used to write programs, even global keywords.