问题描述
为什么反序列化没有恢复我的阵列?见下面的代码..
How come unserialize isn't restoring my array? See code below..
// prints a:1:{s:8:"txn_type";s:32:"recurring_payment_profile_cancel";}
echo $item['response'];
// prints nothing
print_r(unserialize($item['response']));
我明白为什么 print_r($response) 什么都没给我
I understand why the print_r($response) gives me nothing
** 编辑 - 我注意到这一点
** edit - I noticed this
注意:unserialize() [function.unserialize]:第 13 行/home/reitinve/public_html/action/doc.php 中 2797 字节的偏移量 6 处出错
Notice: unserialize() [function.unserialize]: Error at offset 6 of 2797 bytes in /home/reitinve/public_html/action/doc.php on line 13
这是什么意思?
推荐答案
是否有可能 $item['response']
在它之前或之后包含一些空格?
Is it possible $item['response']
contains some whitespace before or after it?
检查 strlen($item['response'])
给你 61.
它似乎在结尾处使用空格,但开头的空格会使其无法反序列化.
It seems to work with whitespace at the end, but whitespace at the start will make it fail to unserialize.
该错误消息意味着您有很多空白(几乎 2kb),或者 $item['response']
在 echo
和 反序列化
that error message means either you have a LOT of whitespace (almost 2kb of it), or $item['response']
is being changed between the echo
and the unserialize
这篇关于PHP反序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!