Ask a basic question: Can I display the declared variables? If you use a variable $ c & quot; aaa & quot; in the function class, the engine first searches for this variable globally and creates it after it is not found? ------ Solution -------------------- what do you mean ?? If it cannot be found, it cannot be found. If you look for $ c in the function, it is a local variable, and he will not make a claim to find the global variable or create it automatically. If you use it, you will not have it. ------ Ask a basic question: Can I display the declared variables?
If a variable is used in the function class
$ C = "aaa ";
The engine first looks for this variable globally. can't it be found before creating it?
------ Solution --------------------
What do you mean ?? If it cannot be found, it cannot be found. If you look for $ c in the function, it is a local variable, and he will not make a claim to find the global variable or create it automatically. If you use it, you will not have it.
------ Solution --------------------
Does php display and implicit declaration? I don't know.
------ Solution --------------------
Declare to global
------ Solution --------------------
Yes, it's global!
------ Solution --------------------
Global $ aaa; global variable declaration in the class, but global variables are not used in the class, so the reusability is not high, and debugging and tracing a global variable is more troublesome than a local variable.
------ Solution --------------------
Unless declared as global, PHP is local by default.
------ Solution --------------------
Global means I want to use this variable now. I have defined this variable as early as "somewhere else ".
And $ GLOBALS ['var ']).
Definitions in php differ greatly from those in C ++ java.
$ C = "aaa"; if the memory contains "aaa"
It may be that a pointer is redirected without declaring aaa.