19

I need to turn off E_STRICT. I have error_reporting = E_ALL & ~E_STRICT in my php.ini but it seems to be ignored. I tried this in my code:

ini_set('error_reporting', E_NOTICE);

Nothing!

Please help.

hakre
  • 193,403
  • 52
  • 435
  • 836
rtacconi
  • 14,317
  • 20
  • 66
  • 84
  • Are you sure that your php.ini file is not being over-riden somewhere else? Is there a more local version of the php.ini file? – Jeff Fohl May 17 '10 at 17:00
  • Instead of turning off errors, you should actually rather fix your code so it won't even throw anything.. – poke May 17 '10 at 17:08
  • poke: I know that thanks, but I have a framework too, the app is in production and is ok and I do not have the time! – rtacconi May 18 '10 at 09:34
  • @rtacconi: "Nothing!" - you wrote, but you didn't mention what kind of errors you got. Are you sure it's related to the `E_STRICT` error reporting? – Sk8erPeter May 10 '12 at 13:46
  • Is it possible that your framework is using ini_set and adding E_STRICT back in later on? – pauld Aug 02 '13 at 17:26

5 Answers5

10

try this.

error_reporting(E_ALL ^ E_STRICT);

This will report all errors except E_STRICT

Community
  • 1
  • 1
Dinesh Nagar
  • 768
  • 2
  • 11
  • 23
5

If you've got your own error handler (search your code for set_error_handler), then the error_reporting config value will be ignored:

It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.

http://php.net/manual/en/function.set-error-handler.php

Also removing E_STRICT from the error_reporting config could fail, if the error occurs in the same file where error_reporting(...) (or ini_set('error_reporting, ...')) is called.

stofl
  • 2,950
  • 6
  • 35
  • 48
  • +1 because this was the answer that helped me most here. I created a hook class called ExceptionHook in CodeIgniter which calls an error handler like this: `set_error_handler(array('ExceptionHook', 'exception_error_handler'), E_ALL);` If I pass E_STRICT to the second argument, a key legacy library fails so I needed to switch off E_STRICT errors. – DavidHyogo Mar 14 '14 at 10:35
  • agree, most helpful one. Internet is full of ^/~E_STRICT things but my issue was in error_handler.. cool! – Vitaly Dyatlov Jul 21 '15 at 12:19
2

You mentioned you're using a framework (would be good to know which one) anyway you can add something like this on the very first index.php:

error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 'On');

But make sure you're on the first index.php that gets called, meaning the very first in the stack, for certain framework that would save you some pain.

Other thing: most of the frameworks have their own config file to address production software VS. development software and they have their own way of doing things, so I would start from there....have a look at the docs and find out if there's anything there you need to change...it could be a super simple change on a config file most likely.

luke
  • 118
  • 4
  • 13
1

I was installing CMS Made simple when I ran into that error but here is how I over came it:

1) Open your php.ini file using any of your favorite editors;notepad, notepad++ or dreamweaver.

2) Press ctrl+f to fire up the find Dialog Box.

3) Type E_STRICT and click ok to jump you to the E_STRICT Line, there several E_STRICT Stuff but look for one with this kind of setting;

Common Values:

E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
 Default Value: E_ALL & ~E_NOTICE
 Development Value: E_ALL | E_STRICT
 Production Value: E_ALL & ~E_DEPRECATED
 http://php.net/error-reporting

error_reporting = E_ALL , here the value with out the ";" is what matters so I just cleared it to:

error_reporting = (delete) and removed the E_ALL, and saved the file, I restarted all the services, and everything worked fine. Hope that works for you too!.

Hamad
  • 5,096
  • 13
  • 37
  • 65
-2
error_reporting(E_ALL & ~E_STRICT);
Bogdan
  • 693
  • 7
  • 26