Re: Serializing of OOP into sessions

From: Date: Wed, 13 Mar 2002 09:16:27 +0000
Subject: Re: Serializing of OOP into sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-88305@lists.php.net to get a copy of this message
>Hello could somone please explain to me HOW I serialize classes into session >and how I get the on the next page!?? > >Must I do $object = new ObjectName on the next page for the object to be >used?? No. Try this. File test.inc------------------------------------------ <?php class Object{ var $name; var $id; function pt(){ print ($this->id).":".($this->name); } } ?> ------------------------------------------------------- File test.php------------------------------------------ <?php require_once("test.inc"); session_start(); session_register("obj"); if(!$obj) $obj=new Object(); $obj->id++; $obj->name.="@"; $obj->pt(); ?> <br><br> <a href='test.php'>Next</a> -------------------------------------------------------- And open test.php with your brouser & click 'Next'. No special serialization is required. Regards, Hiroshi Ayukawa http://hoover.ktplan.ne.jp/kaihatsu/php_en/index.php

« previous php.general (#88305) next »