的file_get_contents功能不能正常工作
问题描述:
我有一些问题file_get_contents()
功能,它不能正常工作时,我试图读取URL像的file_get_contents功能不能正常工作
是可访问的,但是当我试图访问任何像“classes/connect_temp.txt”这样的文件不可访问。
下面是一些代码,我使用
$file_path =realpath('./')."/classes/connect_temp.txt";
$temp_cont = file_get_contents($file_path);
if(empty($temp_cont)){$temp_cont=$this->dbSetings;}
我应该在代码或配置设置改变,我应该怎么检查它。
请帮我在这个问题上
答
启用使用display_errors
和/或error_reporting
错误报告。
+0
它启用,没有错误获取 – 2010-07-15 09:50:00
答
用途:
echo $file_path;
要检查哪些文件中的代码确实在努力阅读。
答
也许试试curl?
样品..
$ch = curl_init("path-to-the-file");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
你得到任何PHP错误?也许该文件不存在或者您无权从中读取。 – 2ndkauboy 2010-07-15 09:37:33
或者你绝对确信$ file_path包含正确的路径? – 2010-07-15 09:59:26
我100%确定$ file_path包含正确的路径并且不会给出任何错误 – 2010-07-15 11:44:27