So I just recently updated our company intranet from PHP 5 to PHP 7 and one change I noticed is that 7 no longer outputs anything if there are non-fatal errors on the page. Consider the following:
echo "Hello World";
echo $undefinedVar1;
echo $undefinedVar2;
In PHP 5, I would get output such as this:
Hello World
PHP Notice: Undefined variable: undefinedVar1 in...
PHP Notice: Undefined variable: undefinedVar2 in...
Now, in PHP 7, I only get the two errors, not the "Hello World" line. It is important to note here, that the code in 7 does NOT halt at the errors since I do get BOTH errors. I just don't get the Hello World text as I would expect. This presents an issue when, for example, I have a division by 0 error on a line with a complex formula. Normally, I'd print out the formula to the screen to see where the 0 error is, but now all I get is the error. I found that I can use exit; or die(); to kill the script just before the offending line and get my output, but that doesn't work in all situations. Consider:
$x = 10;
$y = 3;
for ($z=0; $z<10; $z++) {
echo "Attempt $x / $y: ";
echo ($x/$y)."<br />";
$y--;
}
In 5, I would get this:
Attempt 10 / 3: 3.33333333
Attempt 10 / 2: 5
Attempt 10 / 1: 10
Attempt 10 / 0:
PHP Warning: Division by zero in...
And I could see that the fourth loop is causing the problem because $y is reduced to 0. But in 7, all I get is the error, which tells me nothing other than there's a zero somewhere in the formula. I can't use exit; or die(); because it'll kill the script on the first iteration of the loop, which has no error.
I've checked my error reporting level (which is: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT in both versions) but I don't know what else to check. I looked through other php.ini settings, but nothing else really jumped out at me as being relevant. Please help?