what does means symbol “@” in this output?

时光总嘲笑我的痴心妄想 提交于 2019-12-25 17:44:46

问题


SimpleXMLElement Object(

 [ImageFormat] => SimpleXMLElement Object(

  [@attributes] => Array(

    [DimensionCategory] => small
    [Title] => extra  
  )

  [URL] => link..
 )
)

回答1:


@attributes is derived from this

<ImageFormat DimensionCategory="small" Title="extra">
  <URL />
</ImageFormat>

in another word, is attributes of a given element

see this




回答2:


As knittl stated, it's just a member name. As a note: to access attributes in a SimpleXML node, instead of doing:

echo $xml->ImageFormat->{'@attributes'}['Title'];

One would do:

echo $xml->ImageFormat['Title'];



回答3:


It's simply part of the member name:

echo $xml->ImageFormat->{'@attributes'}['Title'];

You should use the attributes() method of the SimpleXMLElement class to access the attributes of an XML elment.



来源:https://stackoverflow.com/questions/7256396/what-does-means-symbol-in-this-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!