Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问对象中带有美元符号的受保护数组密钥(来自RTM php的响应)?_Php_Arrays_Object_Protected - Fatal编程技术网

如何访问对象中带有美元符号的受保护数组密钥(来自RTM php的响应)?

如何访问对象中带有美元符号的受保护数组密钥(来自RTM php的响应)?,php,arrays,object,protected,Php,Arrays,Object,Protected,在使用php library for RTM()时,我得到了一个特定任务列表的响应,如下所示: [notes] => Rtm\DataContainer Object ( [attributes:Rtm\DataContainer:private] => Array ( [note] => Rtm\DataContainer Object ( [attribut

在使用php library for RTM()时,我得到了一个特定任务列表的响应,如下所示:

[notes] => Rtm\DataContainer Object

(
    [attributes:Rtm\DataContainer:private] => Array
        (
            [note] => Rtm\DataContainer Object
               (
                   [attributes:Rtm\DataContainer:private] => Array
                       (
                           [id] => 56254802
                           [created] => 2016-11-06T10:46:43Z
                           [modified] => 2016-11-06T10:49:26Z
                           [title] => null
                           [$t] => https://stackoverflow.com/questions/910912/extract-urls-from-text-in-php1
                       )

               )

        )

)
我可以获得
id、created、modified的值,但是
$t
不起作用。

$note_obj=$obj->getNotes()->getNote();
$note_id=$note_obj->getId();
回显“$note\u id\n”//很好
$note_content=$note_obj->get{'$t'}()//不起作用
打印(注释内容);

显然
$note\u obj->get{'$t'}在此失败…..那么我如何访问这些数据呢?

我发现所有类的方法都是由一个类似于
toArray
的方法来处理的,用于将对象转换为数组

这些方法也可以通过以下方式公开(正如@Dekel在评论中指出的):

var_dump(get_class_方法($note_obj))给出

array(10) {
[0]=>
string(11) "__construct"
[1]=>
string(11) "getIterator"
[2]=>
string(5) "count"
[3]=>
string(6) "__call"
[4]=>
string(3) "get"
[5]=>
string(3) "set"
[6]=>
string(3) "has"
[7]=>
string(6) "remove"
[8]=>
string(7) "toArray"
[9]=>
string(6) "toJson"
}
因此,守则是:

$note_obj=$obj->getNotes()->getNote();
$rtm_item_note_content=$note_obj->toArray();
$rtm_item_note_content=$rtm_item_note_content['$t'];
echo“备注内容:$rtm\u项目\u备注\u内容\n”;

完成了

试试
$note_obj->{'get$t'}()@Dekel不。那也没用<代码>PHP致命错误:未捕获的BadMethodCallException:未在中实现方法get$thttps://github.com/bartosz-maciaszek/php-rtm/blob/master/src/Rtm/DataContainer.php
…我发现了一种将对象转换为数组的方法。也许这就是路。我将在这里尝试和评论。尝试
var_dump(get_class_方法($note_obj))查看是否有任何特定的方法可以用来获取所有值。哇!。。。它成功了……非常感谢你为我指明了正确的方向。哪种解决方案?:)