1

I'm struggling for an hour, trying to figure out why is PHP showing errors although I suppressed them at the very begginging of my code like this:

error_reporting(E_ALL);
ini_set('log_errors', 1);
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);

I want to log all PHP errors but I don't want to show any of them to the user as this is code for the production.

At the end of the PHP file I check if the ini is set correctly with ini_get('display_errors') and it returns 0 as expected. I also check my whole project and there is no other ini_set() function called, which could override this setting.

Why am I still getting Undefined variable shown to the user?

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined variable: fb_admin</p>
<p>Filename: fb_app/header.php</p>
<p>Line Number: 173</p>

</div>

This is getting frustrating so thanks for any help :)

Edit: Of course I'm aware that I should fix this error, but that's not the point. The point is how to correctly handle other similar, unpredictable errors. I want to log them but not to show them.

Bero_zg
  • 303
  • 1
  • 3
  • 9
  • 1
    instead of hiding the errors , you should fix the errors, it is clearing saying you , that fb_admin variable is undefined , you should use fb_admin = null; as default value and change the value when needed. – Arsh Singh Jun 21 '16 at 10:40
  • This doesn't look like a native php error, might be some library that you're using which prints those errors. – tkausl Jun 21 '16 at 10:41
  • why you are using error_reporting set to `E_ALL`? it will show all errors. – Muhammad Sumon Molla Selim Jun 21 '16 at 10:42
  • @MuhammadSumonMollaSelim because he wants to log all errors, but not display them. – Andy Jun 21 '16 at 10:43
  • 1
    It appears you have a custom error handler defined somewhere using `set_error_handler`. Please show us that code. – Andy Jun 21 '16 at 10:45
  • Looks like CodeIgniter's default error handler to me. Are you using CI? – eggyal Jun 21 '16 at 10:47
  • Yup, I'm using Codeigniter. Of course I will fix this error and define the variable - but that's not the point :) I want to have control of other unpredicted errors that may occur and have them logged, but not shown to the user. Why is my code not doing that? :( – Bero_zg Jun 21 '16 at 10:49
  • I've never used CodeIgniter, but I'd imagine it has it's own display / log errors flag set somewhere. Perhaps this question will help? http://stackoverflow.com/questions/20773786/how-to-disable-php-error-reporting-in-codeigniter – Andy Jun 21 '16 at 10:52

0 Answers0