2

I'd like to turn on error reporting in the document as opposed to the php.ini file on my hosting company's server. According to the manual these functions set the error_reporting directive at runtime so inserting any of these should work, but I'm just getting a blank page. Any suggestions?

error_reporting(E_ALL);
error_reporting(-1);
ini_set('error_reporting', E_ALL);
4
  • 1
    In the real world this doesn't make any difference, but technically you should use ~0 instead of -1 for enabling all errors - but it would only make a difference on an system that does not use two's complement. Also please note that because you are enabling errors at run time, compile time errors (like parse errors) will still not be affected by this, because the code that enables error reporting will never be executed. Commented Dec 16, 2012 at 19:08
  • @DaveRandom, are there any systems out there that both don't use two's complement and can compile PHP? Commented Dec 16, 2012 at 19:33
  • 2
    @Charles Not that I know of off the top of my head, but that doesn't mean they don't exist. Like I say, "In the real world this doesn't make any difference" but I saw an opportunity for pedantry and I took it. Commented Dec 16, 2012 at 19:40
  • That's why I try to ask when things which should work, don't :-) Commented Dec 16, 2012 at 19:46

1 Answer 1

8

First idea is that display_errors is also turned off

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

Second idea is that you have error in your main script and it is not able to switch those options (for example parse error) - in this case you can try to include that script into another one like below:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include('index.php');
Sign up to request clarification or add additional context in comments.

5 Comments

Good thinking about adding display errors :-) It's still not working so it might be the 2nd issue - would you mind explaining that?
explain idea with inclusion or you asked before I added that?
Before :-) I'm going to try that now :-)
That didn't work either :-( Just to make sure that I inserted it where you'd intended - I added it right after session_start(); require_once('config.php);
I'm not sure if you understood correctly - if you have any runtime error (like parse error) in your main php script then inserting that anywhere there won't work cause script won't be executed. you have to create another php file (ex. display_errors.php) and put there only those 4 lines from my second example, then go to yourdomain.com/path/to/page/display_errors.php - you should see whats wrong in your main script. if you would like to add error_reporting to your main script I would suggest to put that on the top of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.