Simple use of PHP mutable variables

Source: Internet
Author: User

Knowledge Points:

mutable variable: Simply put the value of one variable as the name of another variable, e.g. $ A = ' B '; $ $a is $b.

HTML code:

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 </Head>6 <Body>7 <formAction= "show.php"Method= "POST">8 <inputname= "User"><BR>9 <inputname= "Age" ><BR>Ten <inputname= "Email"><BR> One <inputname= "Cellphone"><BR> A <inputtype= "Submit"><BR> - </form> - </Body> the </HTML>

Common PHP Processing:

1 <?php
2 $user=$_post[' User '];3 $age=$_post[' Age '];4 $email=$_post[' Email '];5 $cellphone=$_post[' Cellphone '];6 7 Echo' Name: '.$user;8 Echo' Age: '.$age;9 Echo' Email: '.$email;Ten Echo' Mobile phone number: '.$cellphone; One A -

If the form content is too much, this assignment will also be a lot of operation, here we use variable variable +foreach loop, can be more convenient, as follows:

foreach ($_postas$key$value) {        $$key$value;    } Echo ' Name: '. $user ; Echo ' Age: '. $age ; Echo ' Email: '. $email ; Echo ' Mobile phone number: '. $cellphone ;

Reference post: http://blog.csdn.net/engine_1124/article/details/8660291

Simple use of PHP mutable variables

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.