21,886
社区成员
发帖
与我相关
我的任务
分享
object(SimpleXMLElement)#1 (1) { ["b"]=> string(1) "1" } object(SimpleXMLElement)#2 (1) { ["b"]=> string(1) "1" }
Warning: main() [function.main]: Cannot add element xml number 1 when only 0 such elements exist in PHPDocument1 on line 7
object(SimpleXMLElement)#2 (1) { ["b"]=> string(1) "1" }
<?php
class X implements ArrayAccess {
public $a=1;
public function offsetExists ( $offset ){
if($offset==0)return true;
}
public function offsetGet ( $offset ){
if($offset==0)return $this;
}
public function offsetSet ( $offset , $value ){
if($offset==0) $this->a=$value;
}
public function offsetUnset ( $offset ){
if($offset==0) unset($this->a);
}
}
$m=new X();
print_R($m);
print_R($m[0]);
object(SimpleXMLElement)#1 (1) {
["b"]=>
string(1) "1"
}
object(SimpleXMLElement)#2 (1) {
["b"]=>
string(1) "1"
}
NULL
object(SimpleXMLElement)#1 (1) {
["b"]=>
string(1) "1"
}
object(SimpleXMLElement)#2 (1) {
["b"]=>
string(1) "1"
}
object(SimpleXMLElement)#2 (1) {
["b"]=>
string(1) "1"
}