|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-02-18 19:11 UTC] dubois-holvoet dot patrick at neuf dot fr
Description: ------------ --- From manual page: http://www.php.net/domdocument.save --- Here is the problem. Before using DOMDocument to build a XML structure and save it in a file, I needed to serialize an object witch has to be included in the XML structure. But this object is from a class containing Protected members. And as it's written in the PHP documentation the name of the protected members is prefixed by the serialize function with an asterisc and a nul character on each side of the asterisc. And these nul characters cause the bug with the DOMDocument::save function. The saved file is troncated juste before the first nul character met. Is there a solution to solve that ? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 06:00:02 2025 UTC |
About the use of serialize / unserialize functions along with DOMDocument::save method I've also found a good solution. Here it is. -------------------------- For the serialize : -------------------------- $data_serial = explode("\x00\x2A\x00", serialize($data)); //taking off 'NULL * NULL' string added by the serialize function $serialized_object = implode("\x5C\x30\x2A\x5C\x30", $data_serial); //and replace with the '\0*\0' string -------------------------- For the unserialize : -------------------------- $data_serial = explode("\x5C\x30\x2A\x5C\x30",$obj_serial); //taking off the '\0*\0' string $serialized_object = implode("\x00\x2A\x00",$data_serial); //and replace with the 'NULL * NULL' string as previously added by the serialize operation $object = unserialise($serialized_object); Finally, I've written a note about these solutions onto the PHP documentation witch deal with DOMDocument::save Thanks to you