PHP _construct()函數(shù)講解
PHP _construct() 函數(shù)
實(shí)例
函數(shù)創(chuàng)建一個(gè)新的 SimpleXMLElement 對(duì)象,然后輸出 body 節(jié)點(diǎn)的內(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; ?>
[運(yùn)行實(shí)例»](/try/showphp.php?filename=demo_func_simplexml_construct)
定義和用法
_construct() 函數(shù)創(chuàng)建一個(gè)新的 SimpleXMLElement 對(duì)象。
語法
_construct( _data,options,data_is_url,ns,is_prefix_ );


假設(shè)我們有如下的 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>
實(shí)例 1
從 URL 中創(chuàng)建一個(gè) SimpleXMLElement 對(duì)象:
<?php
$xml=new SimpleXMLElement("note.xml",NULL,TRUE);
echo $xml->asXML();
?>
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
相關(guān)文章
PHP mb_convert_encoding文字編碼的轉(zhuǎn)換函數(shù)介紹
PHP mb_convert_encoding文字編碼的轉(zhuǎn)換函數(shù)介紹,可以將字符轉(zhuǎn)換為gbk或utf8格式。2011-11-11
PHP編程之高級(jí)技巧——利用Mysql函數(shù)
PHP編程之高級(jí)技巧——利用Mysql函數(shù)...2006-10-10
實(shí)現(xiàn)樹狀結(jié)構(gòu)的兩種方法
實(shí)現(xiàn)樹狀結(jié)構(gòu)的兩種方法...2006-10-10
vBulletin HACK----關(guān)于排版的兩個(gè)HACK
vBulletin HACK----關(guān)于排版的兩個(gè)HACK...2006-10-10
一個(gè)阿拉伯?dāng)?shù)字轉(zhuǎn)中文數(shù)字的函數(shù)
一個(gè)阿拉伯?dāng)?shù)字轉(zhuǎn)中文數(shù)字的函數(shù)...2006-10-10

