This article mainly introduces the usage of dynamic variables in php. The example analyzes the usage skills of dynamic variables in php. if you need them, refer to the example below to describe the usage of dynamic variables in php. Share it with you for your reference. The specific analysis is as follows:
Fixed variables defined:
$ My_pic_1 = $ row ["pic_1"]; $ my_pic_2 = $ row ["pic_2"]; $ my_pic_3 = $ row ["pic_3"]; $ my_pic_4 = $ row ["pic_4"]; $ my_pic_5 = $ row ["pic_5"]; $ my_pic_6 = $ row ["pic_6"]; $ my_pic_7 = $ row ["pic_7"]; $ my_pic_8 = $ row ["pic_8"];
Here we use a loop statement to output all the values of each variable:
<? Phpfor ($ I = 1; $ I <= 8; $ I ++) {echo "$ my_pic _". $ I ;}?>
This output
<? Phpecho "$ my_pic _". $ I;?>
Certainly not.
Query php dynamic variable usage and change
<? Phpfor ($ I = 1; $ I <= 8; $ I ++) {$ my_pic_var = "$ my_pic ". $ I; // define the variable name echo $ my_pic_var; // Obtain the variable name $ my_pic_var value $ my_pic_var; // the principle of PHP is as follows: $ my_pic_var = "$ my_pic_1" defines the variable value // $ my_pic_var is equal to the value of $ my_pic_1;}?>
I hope this article will help you with php programming.