0

I added a piece of code that should throw a warning in php

foreach (null as $not_possible) {}

to ensure that my php is setup to report warnings i added this line right before the code above

error_reporting(E_ALL);

this way i don't have to rely on a correctly configured php.ini

Still, as i step through the code over the offending line, php allows me to continue. I would have expected it to suspend execution, but instead it carries on. What is wrong about my setup/reasoning ?


NOTE: I did set error_reporting = E_ALL and display_errors = On in my php.ini file and restarted php. Setting error_reporting(E_ALL); in code was to remove further doubts

4
  • What PHP Version are you using? I've tested this 7.2.8 and it throws a warning as expected: tehplayground.com/oAHvcnnNt1AUtVLP. (Might be worth setting error_reporting(-1); Commented Aug 5, 2020 at 1:38
  • php 7.2.21. And i tried setting ini_set('display_errors',1); in line as in your script but that doesn't work for me Commented Aug 5, 2020 at 1:54
  • 5
    Does this answer your question? Stop script execution upon notice/warning Commented Aug 5, 2020 at 2:01
  • please check this : php.net/manual/en/function.trigger-error.php Commented Aug 5, 2020 at 2:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.