我有一个数组:
Array
(
[0] => BugHerd_Project Object
(
[id:BugHerd_Project:private] => 24323
[name:BugHerd_Project:private] => bugherd a
[devurl:BugHerd_Project:private] => http://st.com/a/
[active:BugHerd_Project:private] => 1
[created:BugHerd_Project:private] => DateTime Object
(
[date] => 2014-05-03 11:15:22
[timezone_type] => 2
[timezone] => Z
)
[updated:BugHerd_Project:private] => DateTime Object
(
[date] => 2014-05-05 06:55:52
[timezone_type] => 2
[timezone] => Z
)
)
)
1。我访问这个数组的代码是:
他们提到的api文档:curl -u api_key:x https://www.bugherd.com/api_v2/projects/1.json
$api = new BugHerd_Api($email,$password);
$projects = $api->listProjects();
$i=0;
on doing print_r($projects[$i]['id:BugHerd_Project:private']);
结果是我的错误,所以我应该如何访问这个数组。
答案 0 :(得分:3)
您正在尝试访问某个类的ID属性,该属性是私有的,因此您无法直接访问它($projects[$i]->id
无法工作)
根据BugHerd_Project类,有一个访问此属性{4}的getter,请尝试getId()