I'm working on a project consisting of several php files.
The settings are similar to:
Code: Select all
//main.php - this file is loaded first
require_once 'act.php';Code: Select all
//act.php
require_once 'lib.php';
$gVar; // $gVar is scoped here
$obj = new Obj();
$obj->foo(); Code: Select all
//lib.php
require_once 'globals.php';
class Obj {
foo()
{
global $gVar;
echo "$gVar"; // $gVar is not scoped here
}
} Code: Select all
//globals.php
$gVar = 0;The problem doesn't exist in this example, but it does in my project, so I geuss have some king of bug.
What might be the reason for a variable to be scoped in including file (act.php) but not in included file (lib.php)?