I am having trouble accessing an object from within another object. In the code below, the broken_links() function cannot see the $search object. When I var_dump $search, it comes up NULL. $search can see $rules just fine, but $rules cannot see $search.
If I take the contents of main() out of the function and put them in the main stream, everything works fine. I tried making the objects static, but I got errors when I tried to use them (Call to a member function on a non-object)
TIA
<?php
main();
function main()
{
$rules = new rules;
$search = new search;
$search -> crawl();
}
class search
{
function crawl()
{
global $rules;
$rules -> apply_rules();
}
}
class rules
{
function apply_rules()
{
global $search;
var_dump($search);
}
}
?>