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

Nicola Pedretti
  • 4,831
  • 3
  • 36
  • 42
  • What PHP Version are you using? I've tested this 7.2.8 and it throws a warning as expected: https://tehplayground.com/oAHvcnnNt1AUtVLP. (Might be worth setting `error_reporting(-1);` – Darren Aug 05 '20 at 01: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 – Nicola Pedretti Aug 05 '20 at 01:54
  • 5
    Does this answer your question? [Stop script execution upon notice/warning](https://stackoverflow.com/questions/10520390/stop-script-execution-upon-notice-warning) –  Aug 05 '20 at 02:01
  • please check this : https://www.php.net/manual/en/function.trigger-error.php –  Aug 05 '20 at 02:52

0 Answers0