下面的代碼在一臺服務器上不起作用,但在其他服務器上正常工作。我得到這個錯誤:Curl不能在一臺服務器上工作,但在所有其他服務器上都可以使用
Warning: simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: HR line 1 and body in testchecker.php on line 11
Warning: simplexml_load_string(): dden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.20</h3></body> in testchecker.php on line 11
Warning: simplexml_load_string():^in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: HR line 1 and html in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Premature end of data in tag body line 1 in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Premature end of data in tag html line 1 in testchecker.php on line 11
Warning: Invalid argument supplied for foreach() in testchecker.php on line 12
<?php
set_time_limit(0);
$url="http://test";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);
foreach($xml->User as $child){
echo $child->Id."<br/>";
}
?>
我不明白爲什麼這個錯誤越來越多,因爲在本地和其他服務器工作正常。在dreamhost上,它不是。任何人都可以幫助我。
1)如果您可以將文本信息粘貼到問題中,則不要使用printscreen; 2)在您的代碼中指出錯誤抱怨哪些行。 – fvu
已更新,請參閱 –
1 - 驗證已安裝php5-curl軟件包 – Fky