开发者

Accessing Class Properties with Spaces

开发者 https://www.devze.com 2023-03-27 03:42 出处:网络
stdClass Object ([Sector] => Manufacturing [Date Found] => 2010-05-03 08:15:19) So 开发者_Python百科I can access [Sector] by using $object->Sector but how can I access [Date Found] ?You can

stdClass Object ([Sector] => Manufacturing [Date Found] => 2010-05-03 08:15:19)

So 开发者_Python百科I can access [Sector] by using $object->Sector but how can I access [Date Found] ?


You can do it this way:

$object->{'Date Found'}


have you tried

$property = 'Date Found';
$object->{$property};

Or simply

$object->{'Date Found'};


try

$var="Date Found"; $this->$var

But I doubt that much you can have spaces in class properties names in php

0

精彩评论

暂无评论...
验证码 换一张
取 消