note 88162 added to ref.simplexml
| From: | ideonexus at osu1 dot php dot net | Date: | Tue, 13 Jan 2009 13:07:09 +0000 |
| Subject: | note 88162 added to ref.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149139@lists.php.net to get a copy of this message | ||
Thanks for posting such a great workaround for serializing simpleXML php at werner dash ott dot de.
It was a real lifesaver.
One minor problem with it, is that it returns:
[[E_WARNING] unserialize() [function.unserialize]: Node no longer exists
On of my peers found that adding a __sleep function to your SimpleXMLSessioned class took care of
it:
<?php
class SimpleXMLSessioned
{
private $o_XMLconfig = null;
private $s_XMLconfig = '';
public function __construct($args_configfile)
{
$this->o_XMLconfig = simplexml_load_file($args_configfile);
$this->s_XMLconfig = $this->o_XMLconfig->asXML();
} // __construct()
public function __destruct()
{
$this->s_XMLconfig = (string)$this->o_XMLconfig->asXML();
unset($this->o_XMLconfig); // this object would otherwise crash
// the subsequent call of
// session_start()!
} // __destruct()
public function __sleep()
{
return array('s_XMLconfig');
}
public function __wakeup()
{
$this->o_XMLconfig = simplexml_load_string($this->s_XMLconfig);
} // __wakeup()
public function getSimpleXMLObject()
{
return $this->o_XMLconfig;
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 152.121.17.40
----
Manual Page -- http://www.php.net/manual/en/ref.simplexml.php
Edit -- https://master.php.net/note/edit/88162
Del: integrated -- https://master.php.net/note/delete/88162/integrated
Del: useless -- https://master.php.net/note/delete/88162/useless
Del: bad code -- https://master.php.net/note/delete/88162/bad+code
Del: spam -- https://master.php.net/note/delete/88162/spam
Del: non-english -- https://master.php.net/note/delete/88162/non-english
Del: in docs -- https://master.php.net/note/delete/88162/in+docs
Del: other reasons-- https://master.php.net/note/delete/88162
Reject -- https://master.php.net/note/reject/88162
Search -- https://master.php.net/manage/user-notes.php