0
我在CentOS和nginx上使用函數「file_get_contents」時遇到了麻煩。PHP「file_get_contents()」函數返回null
error_reporting(E_ALL);
$file = "/srv/http/php/cms/extern/ip/pc.htm";
if (@is_file($file) === false) {// it is true;
$result['error'] = 'no file';
}
if (@fopen($file, "r") === false) { // it is true
@fclose($htmlFilePath);
}
$htmlContent = file_get_contents($file); // return null
我打開htm文件瀏覽器時,它可以幹活在谷歌搜索的東西,那麼我確認在php.ini中的選項:
allow_url_fopen = On;
和殘疾人的功能列表唐」沒有包括那個;
然後我重新啓動nginx和centOS。但它不能工作-_-!
請幫忙,告訴錯誤在哪裏。謝謝!
您確定有內容嗎?你也可以設置'ini_set('display_errors',1);'開始查看是否有錯誤彈出。 – Janno
file_get_contents函數僅在使用完整網址時才起作用。設置你可以在瀏覽器中打開的網址 –
@Janno感謝您的建議,但它不會報告任何錯誤 –