Android Programmer learns PHP Development (4)-variable variable variable reference-phpstorm

Source: Internet
Author: User
Tags learn php
do not map, print results are written directly in the code, than the stickers clear.

<?php/** * The following 4 lines, the official term, variable variables.     * I call it a dynamic assignment variable name.     * This can only be played in PHP, because there are $ characters before the variable name in PHP.    */$x = "a";    $ $x = "B";    $$ $x = "C";    $$$ $x = "D"; echo $x;    The printed result is a echo "<br>"; echo $ $x;    The printed result is b echo "<br>"; echo $$ $x;    The printed result is C echo "<br>"; echo $$$ $x;    The printed result is D-echo "<br>"; echo $x;    The printed result is a echo "<br>"; echo $a;    The printed result is b echo "<br>"; Echo $b;    The printed result is C echo "<br>"; Echo $c;    The printed result is D-echo "<br>";    /** cannot print $d because there is no this variable *//** * Below is a variable reference */$m = 10;    $n = 20; $y = & $m; Y refers to the value of m, equal to said Y is the alias of M Echo $y;    The result of the printing is "<br>";    $m = $n; Echo $y;    The result is the echo "<br>"; /** * Variable Reference 1: * If the referenced variable is freed, * the value before the release is preserved */unset ($m);        Releases the given variable if (Isset ($y)) {//This variable exists echo "This variable exists";//M is released, but Y saves the value of m before release echo "<br>"; Echo $y;    The result is the echo "<br>"; }else{echo "This variable does not exist ";    } if (Isset ($m)) {//This variable does not exist in echo "This variable exists";    }else{echo "This variable does not exist";//M is released so there is no echo "<br>";    }/** * Variable reference 2: * Referencing the second variable automatically relieves the reference relationship to the first variable */$p = 66; $q = & $p; Q refers to the value of P, which means that Q is the alias of P Echo $q;    The result is the echo "<br>";    $r = 77; $q = & $r; Q refers to the value of R, that is, Q is the alias of R Echo $q;    The result is the echo "<br>"; $q = 88; We change the value of Q, see if P, R will change Echo $p;    The printing results for 66,p No change, stating that Q and P lifted the reference relationship echo "<br>"; Echo $r; The result of the printing is 88,r into the value of Q, stating that Q and R form a new citation relationship echo "<br>";

The above is the Android programmer to learn PHP development (4)-Variable variable variables reference-phpstorm content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    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.