I believe that many students who come from c++/java/c# may make such mistakes:
<?php for($i=0;$i<9;$i++) { #some code #many many code!... for($i=0;$i<8;$i++) { #some my ugly code } } ?>
It turns out that the for statement is not a function, but a form of statement. In php, both i are treated as global variables. Every time the loop inside is run, i is reassigned to 7, of course forever. There is no way to break out of the cycle.
My solution is to try to separate the names of the auto-incrementing variables in each for loop, which can greatly avoid this problem. And try to use foreach.
The above introduces the interleaving of local variables and global variables in PHP (1) Variables in nested for loops, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.