请教一下php json串无法通过json_decode($json,true)方法转换

浏览:4015 发布日期:2014/11/01 分类:求助交流
通过php curl get方式来获取json串,json串无法通过json_decode($json,true)方法转换成数组。demo如下:
public function test1(){
$user=array();
$user["user"]="admin";
$user["pwd"]="123456";
echo json_encode($user);
}
public function get(){
$link="http://***/test1/";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo "json:".$json."<br>";
echo "<pre>";
print_r(result );
exit;
}
能输出json串,但无法打出来数组数据。
最佳答案
评论( 相关
后面还有条评论,点击查看>>