note 88162 deleted from ref.simplexml by danbrown
| From: | danbrown@php.net | Date: | Wed, 14 Jan 2009 01:06:50 +0000 |
| Subject: | note 88162 deleted from ref.simplexml by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149165@lists.php.net to get a copy of this message | ||
Note Submitter: ideonexus
----
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;
}
}
?>