php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11163 Serialize an object which has another object
Submitted: 2001-05-29 01:35 UTC Modified: 2001-08-31 11:21 UTC
From: rh98aa at sandcastle dot cosc dot brocku dot ca Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.5 OS: any
Private report: No CVE-ID: None
 [2001-05-29 01:35 UTC] rh98aa at sandcastle dot cosc dot brocku dot ca
I could not believe that serialize does not serialize an object inside of an object especially since arrays work and they are an object right?

If I am incorrect please explain.
Thank you



<?
		class test {
				function toString(){
					print "test test test test test";
				}	//toString()
		} //User	

		
		class User {
				var $firstName; //first name
				var $test;	//The type of user  test purposes
				function User ($fn,$obj){
					
					$this->firstName=$fn;		
					$this->test= $obj;
				}	//constructor
				function toString(){
					print "user user user user	";	
				}	
		} //User	


$temp =new user ('aaa',new test());
$temp->toString();
print"<br>";
$temp->test->toString();

$temp2=serialize($temp);
print"<br>$temp2";
$temp3=unserialize($temp2);
print"<br><br><br>";
print(get_class($temp3));
print"<br><br><br>";
$temp3->toString();
print"<br><br><br>";
$temp3->test->toString();

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-31 11:12 UTC] sander@php.net
Not a bug. 
Making it a feature request.
 [2001-08-31 11:21 UTC] thies@php.net
please update to 4.0.6 - i cannot reproduce any faulty 
behaviour.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC