- Why Your PHP Website Does Not Show Errorr When You Load A Page
this page will help you troubleshoot on how you can display or show your php errors when you are debugin your code with a simple configuration in your web server , Last Updated: Sun Jun 14, 2020
Mon Nov 06, 2006
maintiaing a website if very difficutl. there are always people who will abuse spamming comments for many different websites. when i started my website, i used to have a guest comments page, but then i would see so many spam. i use this php function to detect some spam., there were times when i need to debug my script by showing the errors on my website.. web servers now a day have display_errors off by default, you can use the function phpinfo() if you dont know how your server is setup.. or you can view it in your php configuration file called php.ini.. this is how the php.ini file would look like:
; - display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should have this
; directive set to off.
; Print out errors (as a part of the output). For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = On
As you have read from the php.ini file above, having the display_errors on could have a security issue. so many web hosting companies turn it off, this is to protect your website from harm.
One way to display erorrs while the display_errors is off in the php.ini file, is to create write these functions at the beginning of your script files (.php files)copy and paste this code
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
i hope this helps.