You can store your object in $_SESSION[] if you need to maintain it throughout many page views. Keep in mind you can't have session_autostart turned on if you wish to include user objects in the SESSION global array, since it needs to load the class definition before the session is started.
See here for more info:
http://www.php.net/manual/en/ref.session.php
Ezzaral
Posting Genius
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
I made the following change and it works fine
<?php //instantiate.php
require('animal.inc');
session_start();
$dog = new Animal("Woof!");
$_SESSION['dog'] = $dog;
?>
<?php //call.php
require('animal.inc');
session_start();
echo " a dog goes woof";
$dog = $_SESSION['dog'];
//error on next line
$noise = $dog->makeNoise();
echo "<BR><B>$noise</B>";
?>
The only change was to provide 'dog' as the key in the session array.
Ezzaral
Posting Genius
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847