PHP _construct()函數(shù)講解
PHP _construct() 函數(shù)
實例
函數(shù)創(chuàng)建一個新的 SimpleXMLElement 對象,然后輸出 body 節(jié)點的內(nèi)容:
<?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML; $xml=new SimpleXMLElement($note); echo $xml->body; ?>
[運行實例»](/try/showphp.php?filename=demo_func_simplexml_construct)
定義和用法
_construct() 函數(shù)創(chuàng)建一個新的 SimpleXMLElement 對象。
語法
_construct( _data,options,data_is_url,ns,is_prefix_ );


假設我們有如下的 XML 文件,"note.xml":
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
實例 1
從 URL 中創(chuàng)建一個 SimpleXMLElement 對象:
<?php
$xml=new SimpleXMLElement("note.xml",NULL,TRUE);
echo $xml->asXML();
?>
總結
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內(nèi)容請查看下面相關鏈接
相關文章
PHP mb_convert_encoding文字編碼的轉(zhuǎn)換函數(shù)介紹
PHP mb_convert_encoding文字編碼的轉(zhuǎn)換函數(shù)介紹,可以將字符轉(zhuǎn)換為gbk或utf8格式。2011-11-11
一個阿拉伯數(shù)字轉(zhuǎn)中文數(shù)字的函數(shù)
一個阿拉伯數(shù)字轉(zhuǎn)中文數(shù)字的函數(shù)...2006-10-10

