0

There are a TON of answers on SO about disabling PHP Strict Standards messages, but what I really want to know is, are "Strict standards" messages "Errors"?

Maybe I'm old school, but I've always considered them errors to be fixed -- to me, properly coded PHP scripts shouldn't generate any errors, period. But I'm seeing so many answers saying "they're not errors" and just "turn off error reporting"... but why would you have to tweak error reporting settings if they're not errors?

Bottom line: are "strict standards" messages "errors" or not? Is there a definitive answer somewhere?

David R.
  • 684
  • 6
  • 12
  • Yes, they're notice class warnings. `E_NOTICE` = `0x0008` and `E_STRICT` = `0x0800`. The error level however is kinda irrelevant. Cause and implication are. "Fixing" everything without considering context is just cargo cult programming. – mario Mar 19 '15 at 15:31

2 Answers2

3

Technically they are notices, not errors. Though a 'notice' about an issue with your code can certainly be considered an error at some level, just an error where PHP can gracefully keep going.

I have two large applications that I work on. One is about 10 years old, riddled with thousands of strict notices. So I disable them, it's just not reasonable to go change all that code.

The other application is a relatively new app we are building on Laravel 5. By all means we have strict turned on, and are ensuring that this new app meets strict standards.

So of course it's a good idea to fix them. It improves the quality of your code. Just depends on your situation and how reasonable that is.

JoeCoder
  • 870
  • 5
  • 4
1

The short answer is: No, they're not.

They're warnings you can enable by writing/uncommenting E_STRICT in your php.ini. According to the PHP Docs:

Enable [E_STRICT] to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.

So, basically, if you want PHP to tell you if you're doing something which doesn't follow their "Strict Standards", activate E_STRICT. Otherwise just deactivate it.

For more information on what can be considered not compliant with said standards take a look at this answer. (Or search others in SO, I found a couple more.)

Community
  • 1
  • 1
Alfro
  • 458
  • 9
  • 22