Reputation: 4293
I have a script which similar to this:
foo.php
class Foo
{
function Foo() {
$Registry = array();
include 'bar.php';
$Registry['bar'] = new Bar();
}
}
bar.php
class Bar
{
function Bar() {
global $Registry;
print_r(var_dump($Registry));
}
}
but that returns:
array
'Registry' => &null
Does anyone have any suggestions as to why it's not identifying the Registry
variable as an array?
Upvotes: 0
Views: 77
Reputation: 957
you have to create $register global and outside of your class
$Registry = array();
class Foo
{
function Foo() {
global $Registry;
include 'bar.php';
$Registry['bar'] = new Bar();
}
}
bar.php
class Bar
{
function Bar() {
global $Registry;
print_r(var_dump($Registry));
}
}
Upvotes: 2
Reputation: 53198
Because $Registry
does not exist, Foo->Registry
exists, but that should be access from the object itself.
Upvotes: 0