0

我有这行代码:

print_r($item->figure->iframe);

产生这个输出:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [height] => 288
            [mozallowfullscreen] => true
            [src] => http://www.hulu.com/embed.html?eid=Bq_uuy5X4KWFpYZgwa9e9g
            [allowfullscreen] => true
            [width] => 512
            [frameborder] => 0
            [scrolling] => 0
            [webkitAllowFullScreen] => true
        )

)

然后我试试这个:

var_dump($item->figure->iframe->{'@attributes'}["src"]);

然后给了我这个:

NULL

我究竟做错了什么?我想拿src东西,为什么拿不到?

4

1 回答 1

0
var_dump($item->figure->iframe->attributes());

http://php.net/manual/en/simplexmlelement.attributes.php

于 2013-05-07T22:01:03.850 回答