为什么以下代码中的第二个echo行返回( string )'first'而不是数组?
代码:
<?php
$foo = simplexml_load_string(<<<EOF
<?xml version='1.0'?>
<document>
<body>
<content>first</content>
<content>second</content>
</body>
</document>
EOF
);
echo '<pre>$foo entire object:', "\n", print_r($foo, true), "\n";
echo '$foo->body->content: ', "\n", $foo->body->content;
?>
结果:
$foo entire object:
SimpleXMLElement Object
(
[body] => SimpleXMLElement Object
(
[content] => Array
(
[0] => first
[1] => second
)
)
)
$foo->body->content:
first