4

My webhosting provider doesn't offer the option to enable error reporting. So tried it with error_reporting(E_ALL); But this also doesn't work. I tried the following script:

 <?php
 error_reporting(E_ALL);
 echo $test;
 ?>

If I read the manual correctly, then this should generate an error notice. But this also doesn't work. Did I make something wrong or is the only solution to get a new webhosting provider?

1
  • Set it in your PHP.ini #display_error must be on Commented Apr 11, 2012 at 9:38

4 Answers 4

11

error_reporting is just telling PHP how verbose the error reporting should be, but you also need to tell it to actually display errors out to the browser by setting

ini_set('display_errors', 1);
Sign up to request clarification or add additional context in comments.

1 Comment

still not enough
5

You probably want to do something with the triggered error, such as logging it:

ini_set('error_log', '/path/to/php-error.log');

... and/or displaying it:

ini_set('display_errors', true);

Please find additional documentation at Error Handling and Runtime Configuration.


Addendum: this directive used to be documented as boolean but it's no longer the case. Also, since both the display_errors directive and ini_set()'s second argument are of string type, when using strict types you won't be able to pass a boolean:

<?php
declare(strict_types=1);
ini_set('display_errors', true);

Fatal error: Uncaught TypeError: ini_set() expects parameter 2 to be string, bool given

Thus you'll need to pass a string that evals to true such as 'true' or '1'.

Comments

2

You also need:

ini_set('display_errors', true);

Comments

2

If its a shared hosting then for security reasons, they may disable error reporting, still they should be able to provide error log for your particular domain, try talking to them if they don't want to show it inline - get access go log file or maybe some adminpanel that can read it securely.

Comments

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.