[Basic] PHP variables and variable scopes-wildfox's new PHP, interesting syntax, record.
1. Scope of variables
The scope can only be divided into two Global and Local. compared with the entire. php file, Global is the smallest Local range and the closest range to the variable. for example, in a function, the class is medium.
2. variable declaration
It may be because the PHP variable has a unique $ symbol, so it does not need keywords to declare the PHP variable (except in the class). it is automatically created when the first value is assigned.
The class is quite unique. because the class has the member attributes private, public, and protected, you need to modify keywords when declaring variables in the class. The preceding keyword or var is used, but the two cannot be shared.
3. example
1
VarClass. "\ r \ n ". 32 "VarClass2 = ". $ this-> VarClass2. "\ r \ n ". 33 "VarFunction = ". $ VarFunction. "\ r \ n"; 34 35 36 return str_replace ($ GLOBALS ['NR '],"
", $ Temp); 37} 38 39 40 41} 42 43 $ MyClass = new TestClass (" success "); 44 echo $ MyClass-> GetAllVar (); 45 46?>