php URL file-access is disabled in the server configuration

  升級到php5.2.3後,使用include()包含外部文件,會出現錯誤:URL file-access is disabled in the server configuration….

解決辦法:修改php.ini,allow_url_include = On ,

然後重啓web服務器。

再刷新看看,ok !

但是這對網站安全性會照成危害。

最好還是使用curl代碼 

<?php

/* 

* @return string 

* @param string $url 

* @desc Return string content from a remote file 

* @author Luiz Miguel Axcar ([email protected]

*/ 

function get_content($url) 



$ch = curl_init(); 

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HEADER, 0); 

ob_start(); 

curl_exec ($ch); 

curl_close ($ch); 

$string = ob_get_contents();

ob_end_clean(); 

return $string; 



#usage: 

$content = get_content ("http://www.php.net");

var_dump ($content); 

?>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章