欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Php 構(gòu)造函數(shù)construct的前下劃線是雙的_

 更新時間:2009年12月08日 02:31:35   作者:  
最近寫php的class時,總是碰到function non object的錯誤,知道是類沒有實例化,但就是不知道錯誤在哪里。

定義和用法

__construct() 函數(shù)創(chuàng)建一個新的 SimpleXMLElement 對象。

如果成功,則該函數(shù)返回一個對象。如果失敗,則返回 false。

語法

__construct(data,options,is_url,ns,is_prefix)
參數(shù) 描述
data 必需。形式良好的 XML 字符串或 XML 文檔的路徑或 URL。
options 可選。規(guī)定附加的 Libxml 參數(shù)。
is_url 可選。規(guī)定 data 參數(shù)是否是 URL。默認是 false。
ns 可選。
is_prefix 可選。

返回值

返回一個表示數(shù)據(jù)的 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的前_是一個,我靠,上次也是這個錯誤,忘了,現(xiàn)在記著了
function __construct()
{}

不是
function _construct()
{}

相關(guān)文章

最新評論