我正在使用某人编写的PHP类来与BaseCamp API进行交互.
我正在做的特定调用是检索待办事项列表中的项目,这很好.
我的问题是,我不知道如何只访问todo-items返回的对象的属性.这是返回对象的var_dump:
object(stdClass)[6]
public 'completed-count' => string '0' (length=1)
public 'description' => string 'Description String' (length=89)
public 'id' => string '12345' (length=7)
public 'milestone-id' => string '' (length=0)
public 'name' => string 'Error Reports' (length=13)
public 'position' => string '1' (length=1)
public 'private' => string 'false' (length=5)
public 'project-id' => string '58904' (length=7)
public 'tracked' => string 'false' (length=5)
public 'uncompleted-count' => string '1' (length=1)
public 'todo-items' =>
object(stdClass)[3]
public 'todo-item' =>
object(stdClass)[5]
public 'completed' => …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的stdClass对象:
stdClass Object ( [key-west] => 1 [disney-land] => 1 )
Run Code Online (Sandbox Code Playgroud)
我试图检索这样的值:
$objectName->key-west
但返回的值是0.为什么?以及如何将其检索为1?
谢谢
可能的重复:
名称中带有点的 php 对象属性
我正在处理 PHP,获取 Microsoft Web 服务返回的对象,并且对象名称中有一个句点!
object(stdClass)#22 (1) {
["DAE.Country"]=>
array(24) {
[0]=>
object(stdClass)#23 (2) {
["CountryName"]=>
string(4) "Asia"
["ID"]=>
string(2) "27"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何在 PHP 中访问名称中带有句点的对象?
$response->DAE_GetCountryListResult->DAE.Country;
Run Code Online (Sandbox Code Playgroud)
和
$response->DAE_GetCountryListResult-['DAE.Country'];
Run Code Online (Sandbox Code Playgroud)
两者都失败了。感谢您的时间。