The variables included in the Include function are not callable.
1.php
echo $a;
2.php
$a = "AAAAAAAAAAAA";
Include ("1.php");
This writes the execution 2.php to be able to obtain the output correctly, but below can not
2.php
function LoadFile ($filename) {
Include $filename;
}
$a = "AAAAAAAAAAAA";
LoadFile ("1.php");
What is this for? Put the include into the function, and the file containing it cannot refer to its variables.
------Solution--------------------
function LoadFile () {
echo $a;
}
$a = "AAAAAAAAAAAA";
LoadFile ();
You'll find out if you try.
------Solution--------------------
Variable scope problem.
You have 1.php include inside the function, then variables declared outside the function cannot work on it. Unless you have a global look inside the function. Or use $globals[' a ' in 1.php instead of $ A.
In addition, I have a colleague who also likes to write a lot of papers, and then everywhere include,
I am very resistant to this practice, resulting in a global variable pollution, often I find a variable is where to declare or declare a variable is very laborious, afraid of causing conflict. And the code is messy.
It is therefore not advisable to use this approach. Try to control the variables in a local, not only for PHP performance benefits, code logic will be more clear.
------Solution--------------------
Well, this is a scope issue.