0

EDIT: I'm an not looking for advice on whether I should do what this question asks, but on how to do it. Also, I don't just want to suppress warnings - as far as I can tell the warning is interpreted as an error and prevents further execution. I want to both suppress the error notice and not have it prevent further execution.

I thought deprecated meant you could still use it, but my Laravel app breaks with [ErrorException] The each() function is deprecated. This message will be suppressed on further calls

I have tried this solution:

Laravel breaks entire app on PHP notices

i.e. putting error_reporting(0) in \app\Providers\AppServiceProvider.php boot() method, but no joy.

Is it possible to suppress this error, or are my only options to use a lower version of PHP or refactor the code?

Robin Andrews
  • 3,514
  • 11
  • 43
  • 111
  • The message is there to help you - although I appreciate it's causing you a problem right now. If you suppress the message the problem remains, and your code will break when (if) you update to a PHP version that doesn't support `each()` at all. You should refactor your code. –  Oct 06 '20 at 22:23
  • Deprecated is the last warning you get before you can't use it anymore, usually there's plenty of discouragements before the deprecation. Just because you *can* use it doesn't mean you *should* use it. If you must use it turn off error reporting just before the point in the code when you use it and then turn it back on. However there is no reason to use `each` – apokryfos Oct 06 '20 at 23:47

0 Answers0