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?
How do I get PHP errors to display?
Moderator: General Moderators
-
nathanjame
- Forum Newbie
- Posts: 1
- Joined: Sun May 06, 2018 11:34 pm
-
protopatterns
- Forum Newbie
- Posts: 9
- Joined: Sun Jan 28, 2018 11:18 am
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:
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:
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.
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:
Code: Select all
error_reporting = E_ALL
display_errors = On
log_errors = On
; No quotes:
error_log = /whatever/dir/you/prefer/php_errors.log
Then, for the sake of redundancy (these will override your php.ini directives), put these 4 functions at the top of your script:
Code: Select all
ini_set("display_errors", "1");
ini_set("log_errors", "1");
ini_set("error_log", "/whatever/dir/you/prefer/php_errors.log");
error_reporting(E_ALL);
-
protopatterns
- Forum Newbie
- Posts: 9
- Joined: Sun Jan 28, 2018 11:18 am
Re: How do I get PHP errors to display?
..Or you could do it the easy way 
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/
Code: Select all
phpinfo();
And you can always overwrite your php.ini settings per-directory:
https://blog.arvixe.com/setting-custom- ... r-website/