function encode_json($str) {  
    return urldecode(json_encode(url_encode($str)));      
}  
  
/** 
 *  
 */  
function url_encode($str) {  
    if(is_array($str)) {  
        foreach($str as $key=>$value) {  
            $str[urlencode($key)] = url_encode($value);  
        }  
    } else {  
        $str = urlencode($str);  
    }  
      
    return $str;  
} 

 

php5.2中做json_encode的时候。中文会被unicode编码,
php5.3加入了options参数,
5.4以后才加入JSON_UNESCAPED_UNICODE,这个参数,不需要做escape和unicode处理。
所以在5.4之前都需要对中文做个处理

 

相关文章:

  • 2021-05-25
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案