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:
i开发者_开发技巧ni_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?
You can change error reporting to E_ALL
using the following line:
error_reporting(E_ALL);
Try adding that to the file.
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.
I just had to do this in one of my scripts. DOMDocument warnings were killing my logs. So, here's what you do:
// First, grab a copy of the current error_reporting level
// while setting the new level, I set it to zero because I wanted
// it off - but you could easily turn it on here
$erlevel = error_reporting(0);
// Then, do stuff that generates errors/warnings
// Finally, set the reporting level to it's previous value
error_reporting($erlevel);
精彩评论