简体   繁体   中英

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

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. You can change the ownership using:

chown username:groupname filename

where username is the webservers username, and groupname is the webserver's groupname.

In your php.ini :

  • if you want an output of the errors : set display_errors to 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)

You could find the different parameters of php.ini runtime configuration here .

After the restart of your web server, if you fall into an unexpected 500 error; 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__) )

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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