Re: Passing An Object to another PHP File?
| From: | Matt McClanahan | Date: | Wed, 14 Jun 2000 02:37:34 +0000 |
| Subject: | Re: Passing An Object to another PHP File? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1807@lists.php.net to get a copy of this message | ||
On Tue, 13 Jun 2000, Andrew MacDonald wrote:
> Well first of all I declared a class, I declare an instance of this
> class in one php file and I would like to know is it possible to pass
> this instance into another php file?
You can serialize an object, but the object methods will not be saved,
only the variables.
For example, to serialize an instance of an object,
$class = new MyClass();
// Serialize
$serialclass = serialize($class);
// Sanitize for transfer across HTTP
$passclass = urlencode($class);
And to recover the object,
$class = unserialize(urldecode($passclass));
Matt