如:
echo $product;
结果为:
{"brand":"佳能","category":"单反相机"}
json_decode解析:
$web=json_decode($product);
这时候你print_r($web);
可以看到:$web是一个对象
stdClass Object
(
[brand] => 佳能
[category] => 单反相机
}
想拿里面的值
echo $web->brand; //得到佳能
如:
echo $product;
结果为:
{"brand":"佳能","category":"单反相机"}
json_decode解析:
$web=json_decode($product);
这时候你print_r($web);
可以看到:$web是一个对象
stdClass Object
(
[brand] => 佳能
[category] => 单反相机
}
想拿里面的值
echo $web->brand; //得到佳能