$array = array(
'host_name' => array(
'ip_add' => '127.0.0.1',
'is_allow' => 0,
),
);
$str = serialize($array);
此值插入我的网站。并使用php函数file_get_contents读取它,我从该页面获得此结果
a:1:{s:9:"host_name";a:2:{s:6:"ip_add";s:9:"127.0.0.1";s:8:"is_allow";i:0;}}
并尝试对其进行反序列化,但它会显示如下通知: -
注意:unserialize():/ Applications / XAMPP / xamppfiles / htdocs / admin
中116字节的偏移5处的错误
答案 0 :(得分:0)
如果你想反序列化你可以使用这样的东西:
<?php
$result = 'a:1:{s:9:"host_name";a:2:{s:6:"ip_add";s:9:"127.0.0.1";s:8:"is_allow";i:0;}}';
$decoded = unserialize($result);
print_r($decoded);
?>
与:
相同<?php
$array = array('host_name' => array('ip_add' => '127.0.0.1', 'is_allow' => 0));
$str = serialize($array);
$decoded = unserialize($str);
print_r($decoded);
?>