0

I have this code which should of course throw a few errors. But no errors are displayed at all, it just loads a blank page. I read PHP not displaying errors even though display_errors = On but it did not help.

<?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    blaswagagsd
    gfdasgyoloeaifs

    echo $_SERVER['SERVER_SOFTWARE'] sdfga
?>

/etc/php5/apache2/php.ini

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

error_reporting = E_ALL
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

I also set the same settings in /etc/php5/cli/php.ini. Of course I restarted Apache after I changed the php.ini. What else can I try?

Community
  • 1
  • 1
Black
  • 18,150
  • 39
  • 158
  • 271
  • check `phpinfo()` and make sure those are the proper .ini files. and check for php_value directives in .htaccess files, other apache .conf files, which can override the .ini settings. – Marc B Nov 10 '15 at 14:18
  • There are multiple `.htaccess` files, how can i find out which is the right one? It found: `./usr/share/doc/debian-reference-common/html/.htaccess` `./usr/share/phpmyadmin/setup/lib/.htaccess` `./usr/share/phpmyadmin/setup/frames/.htaccess` `./usr/share/phpmyadmin/libraries/.htaccess` – Black Nov 10 '15 at 14:22
  • you have to check every single one that could affect the script. e.g. look in the script's directory, and ever parent directory upwards. – Marc B Nov 10 '15 at 14:23
  • 1
    create your .htaccess file in your project. – Nana Partykar Nov 10 '15 at 14:24
  • I created an empty `.htaccess` file in my project folder. Still no errors are getting displayed. What do i have to enter in this ".htaccess" file? – Black Nov 10 '15 at 14:27
  • you tried to ini_set with a string? ini_set('display_errors', "1"); – Paladin Nov 10 '15 at 14:29
  • 1
    @Paladin76 [PHP documentation](http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors) states _Although display_errors may be set at runtime (with ini_set()), it won't have any effect if the script has fatal errors. This is because the desired runtime action does not get executed._ (which is fairly obvious), so the in-script settings wont apply here anyways. And nope, the numeric 1 is correct here. – syck Nov 10 '15 at 14:30
  • i know what is written, i just asked if he tried? i have had some servers when this was important to work! you never know... – Paladin Nov 10 '15 at 14:32
  • ye ye i try as you can see in my given code. – Black Nov 10 '15 at 14:32
  • also, check your "error_log" and "log_errors" in your php.ini – Paladin Nov 10 '15 at 14:33
  • 1
    The .htaccess in your files' directory should contain two lines: `php_value display_errors = On` and `php_value error_reporting = E_ALL`. Could you try that? – syck Nov 10 '15 at 14:33

1 Answers1

0

I solved it, the problem was that there is another "display_errors" somewhere on the bottom of the php.ini, which set display_errors = Off, so changing the first occurence of "display_errors" CAN'T work. Either set this display_errors to On or delete the line. I am wondering why the original creators of php.ini set this trap.

Black
  • 18,150
  • 39
  • 158
  • 271