|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-07-06 15:37 UTC] east at canit dot se
in PHP 4.0.1pl2 something seems to be broke regarding serializing objects of type "stdClass".
A class with an object of type "stdClass" cannot be unserialized and used.
The following example WONT work:
class Foo
{
var $object;
function Foo()
{
$object = mysql_fetch_object($result);
}
}
/* code */
$myfoo = new MyFoo();
$s_myfoo = serialize($myfoo);
$newfoo = new MyFoo();
$newfoo = unserialize($s_myfoo);
/***************/
echo $newfoo->object->what_ever;
gives the following error
"The script tried to execute a method or access a property of an incomplete object" - even though "stdClass" definition exists and is loaded.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 06:00:01 2026 UTC |
Tried again. The following does not work in PHP Version 4.0.1pl2! (works fine in 4.0.0) System Linux heaven 2.2.16 #1 Tue Jun 13 13:58:52 CEST 2000 i586 unknown. Exact Code (needs reloading once) --------------------------------- class Foo { var $object; var $str; function Foo() { $this->object->mytest = "testing"; $this->object->other = "hallo"; $this->str = "the following works"; } } $myfoo = new Foo(); print("creating foo()<br>\n"); $s_myfoo = serialize($myfoo); printf("serializing foo() = %s<br>\n", $s_myfoo); $newfoo = new Foo(); $newfoo = unserialize($s_myfoo); print("unserializing newfoo<br>\n"); print("printing variable...<br>\n"); printf("newfoo->str = %s<br>\n", $newfoo->str); printf("newfoo->object->mytest = %s<br>\n", $newfoo->object->mytest);