【发布时间】:2011-06-05 05:35:37
【问题描述】:
我如何在 php 中访问属性值:
[photos] => SimpleXMLElement Object
(
[@attributes] => Array
(
[page] => 1
[pages] => 1
[perpage] => 24
[total] => 18
)
我尝试了以下方法:
$photos->@attributes['total'] ;
$photos->{'@attributes'}['total'] ;
还有很多变体
【问题讨论】:
-
不要在 SimpleXMLElement 上使用
print_r()。如果你想知道里面有什么,你可以在上面使用->asXML()。