PHP While循环跳过代码

I have a while loop in PHP with various calculations as well as a number of IF/ELSE statements. It is hard coded to loop 100 times or until it is broken if a certain condition is met. Each time the loop iterates it echos a line of text.

On a small number of the iterations I am not getting the echo output to my webpage. It is completely random, sometimes it misses say 1, 13, 50... sometimes it doesn't miss any until after 50 or so. It's really puzzling me as all of the code is successfully executing, just occasionally not being output.

Before anyone mentions, no errors are generated what so ever. I'm not going to post the loop as it is far too large and as mentioned all of the code is error free and successfully executing.

Have you tried doing a var_dump in a test environment and compare it to the same output in the live environment. Possibly a copy of the page/code renamed if you can't? If var_dump isn't an option, check putting an IP address check in your live code and print out the value in something that doesn't return NULL like echo does if it's an invalid or NULL value. An easy test would be:

if($_SERVER['REMOTE_ADDR'] == '192.168.0.1') // whatever your ip is
{
    var_dump($echo_string);
}

That's just an example, but var_dump I've found will tell you what the value is for sure, even if NULL, and you also have to consider that an IF statement might be avoiding your echo or string append in the loop for that value based on a condition.

I have found the problem. In my while loop there is a large IF/ELSE statement and there was one condition that I had forgot to factor in which is quite rare/unlikely to happen. It's all working now and just a schoolboy error.