array(1) {   ["index""/>   array(1) {   ["index"">

 >  기사  >  백엔드 개발  >  用var_dump输出一个对象,带@的属性代表什么?该怎么处理

用var_dump输出一个对象,带@的属性代表什么?该怎么处理

WBOY
WBOY원래의
2016-06-13 13:06:221016검색

用var_dump输出一个对象,带@的属性代表什么?
如var_dump输出一个SimpleXMLElement对象,显示如下

object(SimpleXMLElement)#4 (3) {
  ["@attributes"]=>
  array(1) {
  ["index"]=>
  string(1) "1"
  }
  ["name"]=>
  string(7) "书本1"
  ["story"]=>
  array(3) {
  [0]=>
  object(SimpleXMLElement)#5 (2) {
  ["title"]=>
  string(14) "书本1故事1"
  ["quote"]=>
  string(20) "书本1故事1内容"
  }
  [1]=>
  object(SimpleXMLElement)#6 (2) {
  ["title"]=>
  string(14) "书本1故事2"
  ["quote"]=>
  string(20) "书本1故事2内容"
  }
  }
}

那个还@的["@attributes"]代表什么意思,请举一个类似的class,谢谢

------解决方案--------------------
是你用 SimpleXMLElement 说事,而不是我

PHP code
$a = array( '@abc' => 2);
settype($a, 'object');
echo $a->{'@abc'}; <div class="clear">
                 
              
              
        
            </div>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.