我創建了一個簡單的函數獲取XML非對象:成員函數和
function meteor(){
$request_url = "http://site.com/xml.xml";
$xml = simplexml_load_file($request_url) or die("feed not loading");
return $xml;
}
,但我不能調用此函數:
$xmls = new meteor();
echo $xmls->Kemo->Area;
我沒有任何輸出,因爲流星不是班級。在這種情況下,如何從函數中獲取數據? 在此先感謝
給我們顯示一些錯誤?並嘗試var_dump xml變量。 – RobertPitt 2010-07-02 11:01:22
試試'$ xmls = meteor();'(不帶'new'關鍵字)。 – BoltClock 2010-07-02 11:02:29
@Robert; 「試圖獲取非對象的屬性」,$ xmls = meteor();作品完美。 謝謝 – TheNone 2010-07-02 11:10:18