a.php
Code: Select all
class a
{
// imagine some code her
}
$g_a = new a();Code: Select all
print_r($GLOBALS) // -- їb]BOOKMARK 1ї/b]
class b
{
function printA()
{
global $g_a;
print_r($GLOBALS); // --їb] BOOKMARK 2ї/b]
a::someMethodFromA();
}Code: Select all
include_once "a.php";
include_once "b.php";
b::printA(0;I decide to check for $g_a scope. Suprisingly, in b.php, print_r($GLOBALS) (Bookmark 1) dump all the global variables along with the instance of $g_a. However, once entering the function scope (Bookmark 2), print_r($GLOBALS) yields nothing!
I have to declare the variables as below to get it working
In a.php
Code: Select all
global $g_a;
$g_a = new a();That is...
c is in c:\code
a and b are in c:\code\library
Many thanks in advance!