PHP中的_construct()函数是如何实现构造函数的调用和属性初始化的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计364个文字,预计阅读时间需要2分钟。
phpfunction createSimpleXMLElement($note) { $xml=new SimpleXMLElement($note); echo $xml->body;}
PHP _construct() 函数
实例
函数创建一个新的 SimpleXMLElement 对象,然后输出 body 节点的内容:
<?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() 函数创建一个新的 SimpleXMLElement 对象。
本文共计364个文字,预计阅读时间需要2分钟。
phpfunction createSimpleXMLElement($note) { $xml=new SimpleXMLElement($note); echo $xml->body;}
PHP _construct() 函数
实例
函数创建一个新的 SimpleXMLElement 对象,然后输出 body 节点的内容:
<?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() 函数创建一个新的 SimpleXMLElement 对象。

