You recently edited to say that is happens when you 'include' a file.
Files and Globaling don't really get along. You actually have to Global out and into a file. So if test1.php had this code
$a = 5;
and test2.php had this code:
$a = 3;
and test3.php had this code:
$a = 10;
and finally (Yes, too many files) testMaster.php had this code
include 'test1.php';
include 'test2.php';
include 'test3.php';
echo $a;
There would be an undefined variable error. You would have to go an individually global the variable in each file in order for them all to get set.
Now, I'm pretty sure this wouldn't affect the code you gave us, or if function test()
was included, and then called test();
and right after it you put echo $a;
. But if you define AND call test()
in a separate file than you echo $a
, it would cause a globaling error.
I'm not sure if this answers your question, but yes, this is a flaw in the include system.