php gbk 环境 unserialize utf-8 环境下serialize

 

 

// utf8
function mb_unserialize($serial_str) {
    $serial_str= preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
    $serial_str= str_replace("\r", "", $serial_str);
    return unserialize($serial_str);
}
 
// ascii
function asc_unserialize($serial_str) {
    $serial_str = preg_replace('!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $serial_str );
    $serial_str= str_replace("\r", "", $serial_str);
    return unserialize($serial_str);
}

--------------------- 
作者:傲雪星枫 
来源:CSDN 
原文:https://blog.csdn.net/fdipzone/article/details/38071115 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

posted on 2019-03-25 10:36  bandbandme  阅读(374)  评论(0编辑  收藏  举报