PHP Developers Network
http://forums.devnetwork.net/

How do I get PHP errors to display?
http://forums.devnetwork.net/viewtopic.php?f=6&t=147693
Page 1 of 1

Author:  nathanjame [ Sun May 06, 2018 11:37 pm ]
Post subject:  How do I get PHP errors to display?

I have checked my PHP ini file and display errors is set and also error reporting is E_ALL. I have restarted my Apache web server.

I have even put these lines at the top of my script, and it doesn't even catch simple parse errors. For example, I declare variables with a "$" and I don't close statements";". But all my scripts show a blank page on these errors, but I want to actually see the errors in my browser output.

error_reporting(E_ALL);
ini_set('display_errors', 1);

What is left to do?

Author:  protopatterns [ Mon May 07, 2018 5:49 pm ]
Post subject:  Re: How do I get PHP errors to display?

Go about it systematically:

First, make sure you are using the correct php.ini. PHP usually ends up giving you all sorts of php.ini, but the only one you should be worried about is the one which is linked to your Apache server.

I assume this is just on localhost, not a live site. Are you using Linux or Win? (..or maybe a Mac?) On Win if you're using WAMP, I remember the correct .ini file (that's hooked to Apache) is somewhere in the WAMP tray. If you're using Ubuntu the right one's here: /etc/php/7.0/apache2/php.ini (at least on my machine).

Go into the the ini file, do a search for and set these 4 directives:
Syntax: [ Download ] [ Hide ]
  1. error_reporting = E_ALL 
  2. display_errors = On 
  3. log_errors = On 
  4. ; No quotes: 
  5. error_log = /whatever/dir/you/prefer/php_errors.log 


Restart your Apache.

Then, for the sake of redundancy (these will override your php.ini directives), put these 4 functions at the top of your script:
Syntax: [ Download ] [ Hide ]
  1. ini_set("display_errors", "1"); 
  2. ini_set("log_errors", "1"); 
  3. ini_set("error_log", "/whatever/dir/you/prefer/php_errors.log"); 
  4. error_reporting(E_ALL); 


If this is working, you can figure out what's making it work through process of elimination, e.g., if it stops working when you comment out the ini_set("display_errors", "1") function, then you know you have the wrong php.ini file, etc.

Author:  protopatterns [ Wed May 09, 2018 9:54 am ]
Post subject:  Re: How do I get PHP errors to display?

..Or you could do it the easy way :)

Syntax: [ Download ] [ Hide ]
  1. phpinfo();  


This function gives you 'Loaded Configuration File', among others.

And you can always overwrite your php.ini settings per-directory:

https://blog.arvixe.com/setting-custom- ... r-website/

Attachments:
php-ini.png
php-ini.png [ 23.23 KiB | Viewed 10966 times ]

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/