2013-07-29 40 views
1

如果打開訪問但仍然出現php錯誤,該怎麼辦?allow_url_fopen處於打開狀態,仍然無法獲取數據

Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in ------------- on line 40 

Warning: file_get_contents(http://finance.google.co.uk/finance/info?client=ig&q=NASDAQ:MSFT) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in --------------- on line 40 

enter image description here

+0

你通過命令行或在瀏覽器中使用PHP設置allow_url_fopen=on?兩者都有不同的配置。 – acme

+0

我沒有使用命令行。 –

+1

用'<?php phpinfo()創建一個文件; '>',在瀏覽器中打開它,並檢查哪些php.ini文件被解析。您可能正在編輯錯誤的。 – pduersteler

回答

4

嘗試

ini_set("allow_url_fopen", 1); 
if (ini_get("allow_url_fopen") == 1) { 
echo "allow_url_fopen is ON"; 
} else { 
echo "allow_url_fopen is OFF"; 
} 
print ini_get("allow_url_fopen"); 

,或者你可以嘗試不同的方法

function curl($url){ 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    $return = curl_exec($ch); 
    curl_close ($ch); 
    return $return; 
} 
$string = curl('http://www.example.org/myfile.php'); 

嘗試將此代碼添加到您。 htaccess文件:

php_value allow_url_fopen On 

如果使用wampphp.ini有兩個文件夾C:\wamp\bin\apache\apacheVersion\binC:\wamp\bin\php\phpVersion所以要在這兩個文件

+0

我試過htaccess,它會導致我發生內部服務器錯誤。 –

+0

我想''ini_set()'需要引號。但最重要的是,我認爲它需要是「1」,每個http://php.net/manual/en/filesystem.configuration.php –

+0

不能與'php_value allow_url_fopen 1'一起使用。 –

相關問題