先用一段代碼重現(xiàn)一下問題
乍一看,結(jié)果很讓人費(fèi)解:
復(fù)制代碼 代碼如下:
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
$string =
EOF;
$data = simplexml_load_string($string);
print_r($data);
print_r($data->foo);
?>
復(fù)制代碼 代碼如下:
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
SimpleXMLElement Object
(
[foo] => Array
(
[0] => SimpleXMLElement Object
(
[bar] => hello
)
[1] => SimpleXMLElement Object
(
[bar] => world
)
)
)
SimpleXMLElement Object
(
[bar] => hello
)
復(fù)制代碼 代碼如下:
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
foreach ($data->foo as $v) print_r($v);
foreach ($data->children() as $v) print_r($v);
以上就介紹了too simple too naive PHP中simplexml_load_string函數(shù)使用說明,包括了too simple too naive方面的內(nèi)容,希望對(duì)PHP教程有興趣的朋友有所幫助。
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)