2011-11-07 106 views

回答

2

您可以使用file_get_contents,您可以根據其返回值(失敗時爲false,成功數據)檢查它是否成功。您還可以使用@像這樣以抑制任何警告:

if($data = @file_get_contents($filename)) ... 

最後,使用file_get_contents回到創建SimpleXMLElement對象中的數據使用simplexml_load_string,而不是使用simplexml_load_file。