Author: zhanhailiang Date: 2015-04-17
First, read the include, which highlights that the code included in the include inherits the variable scope of the Include row:
When a file is contained, the code contained in it inherits the scope of the variable for the row in which the include is located. From there, any variables that are available to the calling file at that line are also available in the called file. However, all functions and classes defined in the include file have global scope.
This means that the code in the include can access all of the related variables that are accessible to the line where they are located.
As below, I will write test.php test1.php to verify a very odd notation:
test.php
test1.php
A = 1;
The execution output is as follows:
Object (a) #1 (2) { ["a"]=> int (1) ["B"]=> int (2)} This proves that the code in the include file does inherit the range of variables from the include row, which can be accessed to the $this variable.