编程语言
首页 > 编程语言> > php gbk 环境 unserialize utf-8 环境下serialize

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 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

标签:utf,preg,serialize,gbk,unserialize,replace,str,serial,strlen
来源: https://www.cnblogs.com/bandbandme/p/10592366.html