Programming
Display PHP errors when display_errors is Disabled
1There are some servers where the webmasters or server admin wants to make the server more secure, they will disable the display_errors on the PHP settings.
The php.ini will look like this:
{code type=php}; – 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{/code}
During apps development, u will need to display the errors in order for u to debug the code easily, so u can track what’s the error was.
Add below code on top of your PHP code:
{code type=php}ini_set(‘display_errors’, 1);
ini_set(‘log_errors’, 1);
ini_set(‘error_log’, dirname(__FILE__) . ‘/error_log.txt’); // this is optional
error_reporting(E_ALL);{/code}
Happy coding with PHP.