我的序列化的数据看起来像这样PHP反序列化数据为空,这是为什么?
a:6:{i:0;s:12:"Early humans";i:1;s:32:"Apes And Hominids Dart's Find";i:2;s:36:"The hunter gatherers of South Africa";i:3;s:25:"Early Humans The Eve Gene";i:4;s:50:"Australopithecines, Homo ergaster and Homo sapiens";i:5;s:21:"Landscapes of history";}
当我尝试和反序列化,它原来是空的。
我的代码:
$urlnames = unserialize($row['url_name']);
foreach($urlnames as $names){
echo $name;
}
我在做什么错?
感谢
您应该执行检查的'反序列化()'函数,以确保它unserializes正确;如果参数不能反序列化,那么它将返回false。 类似'if(!$ urlnames = unserialize($ row ['url_name'])){echo'can not unserialize'; }'。如果条件为真,您将知道'$ row ['url_name']'不包含序列化数组。 – Pete171