Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Doesn't Display Errors or Warnings

Tags:

php

I don't know how php.ini was configured since I don't have access to it. But on top of my php code file I have

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

But still, if there is an error, e.g. missing a ")", the page is blank. It is so painful to debug without error message. Why were the errors not shown?

like image 659
Dustin Sun Avatar asked Mar 26 '10 20:03

Dustin Sun


People also ask

How can I see all errors in PHP?

You can show all errors by adding a few lines to your local testing site's settings. php: error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); In addition, navigate to Administration→ Configuration→ Development → logging and errors and select "All messages".

Which of the following PHP directive is used to display all the errors except notices?

error_reporting: It displays all level errors except E-NOTICE, E-STRICT, and E_DEPRECATED level errors. display_errors: By default, the value of display_errors is off.

Is warning error in PHP?

Warning ErrorThe PHP function calls that missing file which does not exist. The warning error does not stop/prevent the execution of the program. The main reason behind generating a warning error is to pass an incorrect number of parameters to a function or to include a missing file.

How do I make PHP ignore warnings?

You can put an @ in front of your function call to suppress all error messages.


1 Answers

Your error is not an execution error, as it's a Parse Error : it happens before the page even starts being executed.

So, the two intructions that you used have not been executed yet when this error is happening... and, so, they have no effect.


A solution that would help with those Parse Errors would be to just not have them ; a couple of things that could help :

  • Using an IDE that can detect wrong PHP code
    • Eclipse PDT, for instance
    • Or netbeans
  • Use php -l your-php-file.php to check if it's valid
like image 200
Pascal MARTIN Avatar answered Oct 06 '22 08:10

Pascal MARTIN