為什么我轉(zhuǎn)出來就是一個(gè) public name的字符串
//對(duì)象轉(zhuǎn)json
class a{
? ?public $name = "public name";
? ?protected $b = 'protected name';
? ?private ?$c = 'private name';
? ?public function show(){
? ? ? ?return $this->name;
? ?}
}
echo "<hr/>";
$obj = new a();
print_r($obj);
$thi = json_encode($obj);
echo $thi;?
為什么我轉(zhuǎn)出來就是一個(gè) public name的字符串
2015-12-27
對(duì)象只有public的屬性才會(huì)轉(zhuǎn)為json中的數(shù)據(jù)