For security reasons, error display in production environments is disabled by default.
But, if you want to display errors in a PHP file for debugging purposes, you can place these lines of code at the top of your PHP file, as shown in the following example:
However, this doesn't make PHP to show parse errors (such as missing semicolon). The only way to show those errors is to set the display_errors directive to On in php.ini file. By default display_errors set to Off for production environments.
display_errors = On
After modifying the php.ini file restart your web server, or php-fpm service if you are using PHP-FPM.
However, if you don't have access to php.ini file—for instance, if you're using a shared hosting—then putting the following line in .htaccess file might also work.
php_flag display_errors 1
Warning: Outputting errors in production environments could be very dangerous. Sensitive information could potentially leak out of your application such as database usernames and passwords or worse. For production environments, logging errors is recommended.
Use the
ini_set()FunctionFor security reasons, error display in production environments is disabled by default.
But, if you want to display errors in a PHP file for debugging purposes, you can place these lines of code at the top of your PHP file, as shown in the following example:
However, this doesn't make PHP to show parse errors (such as missing semicolon). The only way to show those errors is to set the
display_errorsdirective toOninphp.inifile. By defaultdisplay_errorsset toOfffor production environments.After modifying the php.ini file restart your web server, or php-fpm service if you are using PHP-FPM.
However, if you don't have access to
php.inifile—for instance, if you're using a shared hosting—then putting the following line in.htaccessfile might also work.Warning: Outputting errors in production environments could be very dangerous. Sensitive information could potentially leak out of your application such as database usernames and passwords or worse. For production environments, logging errors is recommended.