久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php反序列化失敗怎么辦

      php反序列化失敗是因?yàn)樾蛄谢瘮?shù)據(jù)時(shí)的編碼與反序列化時(shí)的編碼不一致導(dǎo)致的,其解決辦法就是使用處理過的單雙引號(hào),過濾“r”的“mb_unserialize”方法即可成功反序列化。

      php反序列化失敗怎么辦

      推薦:《PHP視頻教程》

      php unserialize 返回false的解決方法

      php 提供serialize(序列化) 與unserialize(反序列化)方法。

      使用serialize序列化后,再使用unserialize反序列化就可以獲取原來的數(shù)據(jù)。

      <?php $arr = array(     'name' => 'fdipzone',     'gender' => 'male' );  $str = serialize($arr); //序列化 echo 'serialize str:'.$str."rnrn";  $content = unserialize($str); // 反序列化 echo "unserialize str:rn"; var_dump($content); ?>

      輸出:

      serialize str:a:2:{s:4:"name";s:8:"fdipzone";s:6:"gender";s:4:"male";}  unserialize str: array(2) {   ["name"]=>   string(8) "fdipzone"   ["gender"]=>   string(4) "male" }

      但下面這個(gè)例子反序列化會(huì)返回false

      <?php $str = 'a:9:{s:4:"time";i:1405306402;s:4:"name";s:6:"新晨";s:5:"url";s:1:"-";s:4:"word";s:1:"-";s:5:"rpage";s:29:"http://www.baidu.com/test.html";s:5:"cpage";s:1:"-";s:2:"ip";s:15:"117.151.180.150";s:7:"ip_city";s:31:"中國北京市 北京市移動(dòng)";s:4:"miao";s:1:"5";}'; var_dump(unserialize($str)); // bool(false) ?>

      檢查序列化后的字符串,發(fā)現(xiàn)出問題是在兩處地方

      s:5:"url"

      s:29:"http://www.baidu.com/test.html"

      這兩處應(yīng)為

      s:3:"url"

      s:30:"http://www.baidu.com/test.html"

      出現(xiàn)這種問題的原因是序列化數(shù)據(jù)時(shí)的編碼與反序列化時(shí)的編碼不一致導(dǎo)致,例如數(shù)據(jù)庫是latin1和UTF-8字符長度不一樣。

      另外有可能出問題的還有單雙引號(hào),ascii字符"