Errors in PHP

To display PHP errors on the web the variables in php.ini need to be change:

vim /etc/php5/apache2/php.ini

; Quick Reference ;
; The following are all the settings which are different in either the production
; or development versions of the INIs with respect to PHP's default behavior.
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.

; display_errors
; Default Value: On
; Development Value: On
; Production Value: On

; display_startup_errors
; Default Value: Off
Development Value: On
Production Value: Off

Restart Apache:
# service apache2 restart

to check if the settings are saved you can use phpinfo(); to display the settings.

It may happened that even the settings in php.ini files are set to show the errors the errors still won’t be displayed as there might be a piece of code overwriting the settings. Then use this piece of code on the top of the file that you suspect is having an error:

ini_set('display_errors', 1); 

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *

2 + 4 =