3

I need to test some functionality on live server and it's obvious that they turned off errors at some global level.

Problem is that I can't work when I don't know what's throwing the error. How can I make sure that exceptions are being shown and not just 500 code.

I have tried putting these two lines at the top of my script but it's still empty.

<?php

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

throw new Exception('Fatal Error'); // nothing is outputed
Stan
  • 25,744
  • 53
  • 164
  • 242
  • `ini_set('display_errors', '1'); error_reporting(E_ALL);` should do. – Prasanth Feb 12 '14 at 13:19
  • Do you get anything in your logs? – Rob Baillie Feb 12 '14 at 13:19
  • Is there not a canonical question for error reporting? http://stackoverflow.com/tags/php/info under "I have a typical "does not work" problem. What should I do before asking a question?". Also http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851, http://stackoverflow.com/questions/5680831/php-does-not-display-error-messages, http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php, http://stackoverflow.com/search?q=%5Bphp%5D+White+Page+Screen+Of+Death – Mike B Feb 12 '14 at 13:26

1 Answers1

2

The two lines are pretty much identical, so remove one of them.

You also need ini_set("display_errors",1); to actually display errors.

Note however that this will not work for syntax errors in the current file, as these occur in the parsing phase, before any statements are actually run.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • Nice to see a mention of errors in the current file. – Anigel Feb 12 '14 at 13:22
  • Thanks, it's working now. But I don't understand the second sentence. How it *will not* work in current file? It's working in current file for me just fine. – Stan Feb 12 '14 at 13:27
  • If you have a syntax error, then it will not attempt to run any of it, therefore the error reporting will not be set, and nothing will appear. – Niet the Dark Absol Feb 12 '14 at 13:44