简体   繁体   English

500内部服务器错误在PHP中引用文件时?

[英]500 internal sever error While referring a file in PHP?

I am facing a problem 500 internal server error while referring a file through PHP 我通过PHP引用文件时遇到500内部服务器错误问题

Here is my code 这是我的代码

<?php
require_once(dirname(__FILE__).'/html2pdf.class.php');
?>

Here I am having the class file in the same folder itself... 这里我将类文件放在同一个文件夹中...

Check the ownership and group for the files giving the error, and the accessrights of the directory they are in. Most probably your webserver cannot access these files. 检查发生错误的文件的所有权和组以及它们所在目录的访问权限。很可能您的Web服务器无法访问这些文件。 You can change the ownership using: 您可以使用以下方式更改所有权

chown username:groupname filename

where username is the webservers username, and groupname is the webserver's groupname. 其中username是webservers用户名,groupname是webserver的groupname。

In your php.ini : 在你的php.ini中

  • if you want an output of the errors : set display_errors to On 如果要输出错误:将display_errors设置为On
  • if you want to see the errors in your log file : set the log_errors to On and the error_log to a string file path (exemple: error_log = /var/log/php-scripts.log) 如果要查看日志文件中的错误:将log_errors设置为On ,将error_log设置为字符串文件路径 (例如:error_log = /var/log/php-scripts.log)

You could find the different parameters of php.ini runtime configuration here . 你可以在这里找到php.ini运行时配置的不同参数。

After the restart of your web server, if you fall into an unexpected 500 error; 重新启动Web服务器后,如果遇到意外的500错误; it may be because of the "@" operator : from the documentation: 可能是因为“@”运算符 :来自文档:

Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. 目前,“@”错误控制运算符前缀甚至会禁用将终止脚本执行的严重错误的错误报告。 Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why. 除此之外,这意味着如果你使用“@”来抑制来自某个函数的错误,并且它不可用或者输入错误,那么脚本就会在那里死亡而没有任何关于原因的指示。

And nothing to do but in php5.3 you can do: ( __DIR__ instead of dirname(__FILE__) ) 除了在php5.3中你无能为力:( __DIR__而不是dirname(__FILE__)

<?php
require_once(__DIR__.'/html2pdf.class.php');
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM