定义和用法
__construct() 函数创建一个新的 SimpleXMLElement 对象。
如果成功,则该函数返回一个对象。如果失败,则返回 false。
语法
__construct(data,options,is_url,ns,is_prefix)参数描述data必需。形式良好的 XML 字符串或 XML 文档的路径或 URL。options可选。规定附加的 Libxml 参数。is_url可选。规定 data 参数是否是 URL。默认是 false。ns可选。is_prefix可选。返回值
返回一个表示数据的 SimpleXMLElement 对象。
例子
<?php$xmlstring = <<<XML<?xml version="1.0" encoding="ISO-8859-1"?><note><to>George</to><from>John</from><heading>Reminder</heading><body>Don't forget the meeting!</body></note>XML;$xml = new SimpleXMLElement($xmlstring);echo $xml->body[0];?>输出类似:
Don't forget the meeting!后来看construct的前_是一个,我靠,上次也是这个错误,忘了,现在记着了
function __construct()
{}
不是
function _construct()
{}