I'm having this problem when I am trying to serialize my class I get the exception
Serialization of 'SimpleXMLElement' is not allowed.
I don't get the error. I am not even using the xml features of PHP.. What does this error mean ?
The code:
$test = 开发者_运维知识库new \My\Name\Space\MyClass();
die(serialize($test));
You have a SimpleXmlElement
in the object graph of the \My\Name\Space\MyClass
instance but it cannot be serialized. Add the magic __sleep
method to influence which properties get serialized and which are ignored or implement the Serializable interface
I just made an array of all my attributes in the class and serialized that one, when I get the array back out of the session I unserialize it and load it back in.
I made 2 extra methods in the class. 1 to get the array, and the other to load the array.
I didn't found where the SimpleXmlElement is used in Symfony 2.
And now it works.
精彩评论