Cannot access object after include
Posted: Sun Feb 07, 2010 10:04 am
The topic title is rather vague so let me explain my problem with a code snippet:
In initialize.php I create an instance of a class (let's name it "Foo") so it is readily available to me by requiring initialize.php. So far so good. By including header.php I include the typical header information that is consistent throughout the website.
However, in this header.php, I want to call the instance of Foo, I made, but it seems I have no access to that instance. How do I go about to have access to that instance of Foo in header.php?
I hope everything is clear. Advise and suggestions are welcome!
Bart
Code: Select all
<?php
require_once("initialize.php");
include("header.php");
?>
body of the page
<?php
include("footer.php");
?>
However, in this header.php, I want to call the instance of Foo, I made, but it seems I have no access to that instance. How do I go about to have access to that instance of Foo in header.php?
I hope everything is clear. Advise and suggestions are welcome!
Bart