Php fopen在服务器上不工作,没有错误
我的代码在Windows环境中的本地PHP实例(版本5.4.31)上运行得非常好 但当我在服务器上运行同一个文件时,它就不起作用了 在Centos环境中的服务器(PHP版本5.4.16)上 我的PHP代码:Php fopen在服务器上不工作,没有错误,php,Php,我的代码在Windows环境中的本地PHP实例(版本5.4.31)上运行得非常好 但当我在服务器上运行同一个文件时,它就不起作用了 在Centos环境中的服务器(PHP版本5.4.16)上 我的PHP代码: <?php //$myfile = fopen("testfile.txt", "w"); if (!file_exists("file.txt")) { die('File does not exist'); } clearstatcache(); // $fh = f
<?php
//$myfile = fopen("testfile.txt", "w");
if (!file_exists("file.txt")) {
die('File does not exist');
}
clearstatcache();
// $fh = fopen("file.txt", "r") or die("can't open file");
$fh = fopen("file.txt", "r") or die($php_errormsg);
$sql = fread($fh, filesize("file.txt"));
error_reporting(E_ALL);
ini_set('display_errors',1);
?>
问题是没有生成文件,因为我无法查看错误日志,我在哪里可以看到错误,以便找到相应的解决方案?通常是这样的:
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
//$myfile = fopen("testfile.txt", "w");
if (!file_exists("file.txt")) { die('File does not exist'); }
clearstatcache();
// $fh = fopen("file.txt", "r") or die("can't open file");
$fh = fopen("file.txt", "r") or die($php_errormsg);
$sql = fread($fh,filesize("file.txt"));
?>
所以它会执行您的代码,然后设置错误报告?我已经编写了
错误报告(E_ALL)代码>我做错了吗?我不确定tbh,但我总是将我的报告设置在文件的顶部(不确定是否有区别,但值得一试),但你将错误报告放在代码下面,放在上面,它就会显示出来,这是正常的you@user2828442你看过医生了吗?请确保您的PHP设置配置正确。如果是安全模式,请确保用户apache
或www-data
拥有该文件夹的权限。仍然相同,它表示文件不存在
,文件未生成,无错误。虽然这有助于错误报告,但并不是对实际问题的回答:)是的,报告错误有效,但是你确定你把你的文件放在同一个文件夹里吗?我忘了告诉你,那里启用了SSL,这是一个问题吗?给我们看看你的项目树,以及文件在哪里?
┬root
|
|
└─┬www
|
├─ test4.php
|
├─ file.txt
|