Examples of dynamic variable usage in php and php variable usage. Examples of dynamic variable usage in php, and examples of php variable usage this article describes the dynamic variable usage in php. Share it with you for your reference. The specific analysis is as follows: fixed variables defined: examples of dynamic variable usage in php, and examples of php variable usage
This example describes how to use 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.
Examples in this article describes how to use dynamic variables in php. Share it with you for your reference. The specific analysis is as follows: fixed variable defined :...