The variables required in the PHP loop block are defined outside the loop or in the loop? For example, does the definition create a variable in each loop? Php: Well, it depends on your needs. this depends on your needs. if you want to use the variables required in the PHP loop block, should they be defined outside the loop or in the loop?
For example, does the definition create a variable in each loop? Php
------ Solution --------------------
Well, let's look at your needs.
------ Solution --------------------
This depends on your requirements. if you want to change the value of a variable, you can use the variable for the next time and put it on the outside. if it is only effective in each loop, it is placed on the inside.
------ Solution --------------------
Can be placed outside, not inside
Can be placed on the outer layer instead of on the internal layer
------ Solution --------------------
If you want to use it multiple times without changing the variable value, we recommend that you put it out. If it is used only in a loop and the value may change, put it in it.
------ Solution --------------------
In my opinion: after using a variable, remember to unset it, so you don't have to worry about it.
------ Solution --------------------
Reference:
Reference: If you want to use it multiple times without changing the variable value, we recommend that you put it out. If it is used only in a loop and the value may change, put it in it.
Each use is a new value.
Agree with the upstairs, not unset. Since the variable values are different, you only need to assign a value to the variable before each use. You don't have to worry about putting it inside or outside.
------ Solution --------------------
The variable will not change during the cycle if it is placed in the external body of the loop as needed; if it is placed in the circulatory body, the variable will change during the cycle
------ Solution --------------------
It is defined outside the loop body. after each use in the loop body, it is initialized to the original state.