[英]How to fix '500 Internal Server Error' while file handling?
I had made a PHP file using fopen and fwrite and I am trying to execute that file but it's giving me 我已经使用fopen和fwrite制作了一个PHP文件,我正在尝试执行该文件,但这给了我
Internal Server Error
内部服务器错误
while making file I had to change the permission to 0775
using chmod
在制作文件时,我不得不使用
chmod
将权限更改为0775
$book="829310_Revolution_Test_(5)-converted_(4).epub.php";
$book=str_replace(" ","_",$book);
$path=$book.".php";
$myfile =fopen("../../include/uploaded/epub/$path", "w") or die("Unable to open file!");
$txt = "<?php include('hello.php'); ?>";
fwrite($myfile, $txt);
fclose($myfile);
chmod("../../include/uploaded/epub/$book", 0775);
chmod("../../include/uploaded/epub/$path", 0775);
I want user can execute this file but while trying to execute this file I am getting an Internal Server Error. 我希望用户可以执行此文件,但是在尝试执行此文件时出现内部服务器错误。
To know exact errors you should turn on the error reporting by adding following lines at the top of your php file: 要了解确切的错误,您应该通过在php文件顶部添加以下几行来打开错误报告:
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
For more info on error reporting, check this page . 有关错误报告的更多信息, 请检查此页面 。
Once you get exact error, you can easily debug the server error. 一旦获得确切的错误,就可以轻松调试服务器错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.