Examples of dynamic variable usage in php and examples of php variable usage _ PHP Tutorial

Source: Internet
Author: User
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 :...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.