curl提交数据时中文乱码

1.使用curl提交数据时中文乱码解决:

<?php  

$testJSON=array('name'=>'中文字符串','value'=>'test');  

foreach ( $testJSON as $key => $value ) {  

        $testJSON[$key] = urlencode ( $value );  

echo urldecode ( json_encode ( $testJSON ) ); 

?> 

注意:json_decode($string,true),第二个参数为true时,返回的结果是数组array而不是对象

posted @ 2015-04-08 16:30  Echo正在输入  阅读(2320)  评论(0)    收藏  举报