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?
Reply to discussion (solution)
Well, let's look at your needs.
Well, let's look at your needs.
Each time a local variable is required in the circulatory body, is this variable well defined in the circulating body or in the circulating body?
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.
Can be placed outside, not inside
Can be placed on the outer layer instead of on the internal layer
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.
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.
In my opinion: after using a variable, remember to unset it, so you don't have to worry about it.
Reference the reply from xianglei1130 on the 6th Floor: 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.
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
It is defined outside the loop body. after each use in the loop body, it is initialized to the original state.