PHP中的stdClass是什么?请定义什么stdClass是。
3 回答
青春有我
TA贡献1784条经验 获得超8个赞
stdClass
Object
object
json_decode()
SoapClient::__soapCall
<?php//Example with StdClass$json = '{ "foo": "bar", "number": 42 }';$stdInstance = json_decode($json);echo $stdInstance->foo . PHP_EOL; //"bar"echo $stdInstance->number . PHP_EOL; //42//Example with associative array$array = json_decode($json, true); echo $array['foo'] . PHP_EOL; //"bar"echo $array['number'] . PHP_EOL; //42
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
stdClass
stdClass
class Foo{}$foo = new Foo();echo ($foo instanceof stdClass)?'Y':'N';// outputs 'N'
至尊宝的传说
TA贡献1789条经验 获得超10个赞
$page=new stdClass();$page->name='Home';$page->status=1;
<?phpclass PageShow { public $currentpage; public function __construct($pageobj) { $this->currentpage = $pageobj; } public function show() { echo $this->currentpage->name; $state = ($this->currentpage->status == 1) ? 'Active' : 'Inactive'; echo 'This is ' . $state . ' page'; }}
$pageview=new PageShow($page); $pageview->show();
- 3 回答
- 0 关注
- 525 浏览
添加回答
举报
0/150
提交
取消