PHP中simplexml对象不能被序列化
来源:互联网 发布:女巫是真的么 知乎 编辑:程序博客网 时间:2024/05/17 04:10
相信经常处理XML的朋友一定会用过simplexml_load_string,他将XML变成对象,十分方便。但如果你想把这个对象序列化后缓存起来,可要小心了。写Cache的时候没有问题,但读取Cache的时候会出错,错误是“Node no longer exists in xxxx.php on line 15“。错误是由于在反序列化simplexml对象时发生的。大概是PHP的Bug吧。
下边的代码可以验证我的经历,以后序列化simplexml对象时要小心了。
php
$data = <<<XML
xml version='1.0'?>
<articles>
<article>
<title>王开源PK比尔title>
article>
articles>
XML;
$xml = simplexml_load_string($data);
$str = serialize($xml);
echo "$str ";
$new_xml = unserialize($str);
echo serialize($new_xml)." ";
?>
$data = <<<XML
xml version='1.0'?>
<articles>
<article>
<title>王开源PK比尔title>
article>
articles>
XML;
$xml = simplexml_load_string($data);
$str = serialize($xml);
echo "$str ";
$new_xml = unserialize($str);
echo serialize($new_xml)." ";
?>
- PHP中simplexml对象不能被序列化
- PHP中simplexml对象不能被序列化
- PHP中simplexml对象不能被序列化
- PHP中simplexml对象不能被序列化
- PHP SimpleXML
- PHP SimpleXML
- PHP SimpleXML
- java simpleXml序列化反序列化小例子
- PHP 对象序列化
- php 序列化对象
- PHP - 应用实例 - 移除SimpleXML对象中的子对象
- 83. PHP 对象序列化
- PHP5中利用SimpleXML对象来操作xml
- 怎样在PHP 中运用 SimpleXML 处理任务
- PHP中利用simpleXML读取XML和追加XML节点
- php中SimpleXML的使用方法,加载XML,解析XML
- php5的simplexml对象
- php5的simplexml对象
- 用mysqldumpslow分析mysql的slow query log
- 彻底解决IIS 500内部服务器错误
- Windows API一日一练(79)GlobalMemoryStatusEx函数
- Windows API一日一练(78)HeapAlloc函数
- 出差见闻(三)--温州的红包:1000元起
- PHP中simplexml对象不能被序列化
- Windows API一日一练(77)VirtualAlloc函数
- Windows API一日一练(76)GlobalAlloc函数
- Windows API一日一练(75)SystemParametersInfo函数
- 出差见闻(二)--温州的房价:250000
- 使用hxcomp.exe反编译MSDN文档
- Windows API一日一练(74)GetSystemInfo函数
- Windows API一日一练(73)GetVersionEx函数
- Windows API一日一练(72)GetUserName函数