Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get PHP errors to display?

I have checked my PHP ini file (php.ini) and display_errors is set and also error reporting is E_ALL. I have restarted my Apache webserver.

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?

like image 519
Abs Avatar asked Jun 27 '09 19:06

Abs


People also ask

How do I find PHP errors?

Look for the entry Configuration File (php. Find the Error handling and logging section of the php. ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log - this tells you the location of the file errors are logged to.

Why does PHP not show errors?

If you have set your PHP code to display errors and they are still not visible, you may need to make a change in your php. ini file. On Linux distributions, the file is usually located in /etc/php. ini folder.

How do I view PHP errors in Chrome?

A: You can easily debug PHP in Chrome using a simple extension called PHP Console. Just install this PHP debugging tool from the Chrome web store and start logging errors, warnings, exceptions, and vars dump on your Chrome browser.

How can I send error message from PHP to HTML?

To show invalid input in PHP, set the name of the input textbox which is in HTML. All the fields are first checked for empty fields and then it is validated for correctness. If all fields are correct then it shows the success message.


2 Answers

This always works for me:

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

However, this doesn't make PHP to show parse errors - the only way to show those errors is to modify your php.ini with this line:

display_errors = on 

(if you don't have access to php.ini, then putting this line in .htaccess might work too):

php_flag display_errors 1 
like image 90
Fancy John Avatar answered Sep 30 '22 00:09

Fancy John


You can't catch parse errors when enabling error output at runtime, because it parses the file before actually executing anything (and since it encounters an error during this, it won't execute anything). You'll need to change the actual server configuration so that display_errors is on and the approriate error_reporting level is used. If you don't have access to php.ini, you may be able to use .htaccess or similar, depending on the server.

This question may provide additional info.

like image 28
Michael Madsen Avatar answered Sep 29 '22 23:09

Michael Madsen