Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On the fly error reporting in PHP

Tags:

php

When our site used to be on IIS hosting with PHP installed, I had error reporting set to E_NONE and was able to turn it on temporarily by using:

ini_set('display_errors', 1);

That command seems to no longer work now that we are on Linux/Apache hosting. I have tried purposely sending bad commands to the server and I get no errors reported.

What am I doing wrong? Is there any other way to temporarily turn on error reporting without having to edit the php.ini each time?

like image 903
sehummel Avatar asked Apr 19 '11 17:04

sehummel


People also ask

How do I report errors in PHP?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

How do I stop PHP error reporting?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <?

What is the meaning of E_error and E_warning in PHP?

This is like an E_WARNING , except it is generated by the Zend Scripting Engine. 256. E_USER_ERROR (int) User-generated error message. This is like an E_ERROR , except it is generated in PHP code by using the PHP function trigger_error().


2 Answers

You can change error reporting to E_ALL using the following line:

error_reporting(E_ALL);

Try adding that to the file.

like image 54
Rocket Hazmat Avatar answered Oct 25 '22 12:10

Rocket Hazmat


The best way to turn on all errors is:

error_reporting( -1 );

This is better than E_ALL, as E_ALL doesn't actually mean all errors in all versions of PHP (it only does in the most recent). -1 is the only way to ensure it's on in all cases.

like image 45
JL235 Avatar answered Oct 25 '22 14:10

JL235