php反序列化问题 [英] unserialize problem in php

查看:51
本文介绍了php反序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php 5.2 中使用序列化/反序列化函数.要存储的文本通过表单发布.顺便说一句,前后没有空格.如果文本包含 " 或 ' 它会成功序列化.问题是它不会反序列化.我做错了什么?

i'm using serialize/unserialize functions in php 5.2. the text to be stored is POSTed via a form. btw, no white-space before or after. if text contains " or ' it serializes successfully. the problem is it does not unserialize back. what i'm doing wrong?

推荐答案

David Walsh 有一个简单的解决方案:

David Walsh has a simple solution:

//to safely serialize  
$encoded_serialized_string = base64_encode(serialize($your_array));  

//to unserialize  
$array_restored = unserialize(base64_decode($encoded_serialized_string));  

http://davidwalsh.name/php-serialize-unserialize-issues

这篇关于php反序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆