PHP Quote &

Source: Internet
Author: User
PHP References &

PHP refers to the meaning of &

?

Such as:

function &test ()
{
Static $b =0;//declaration of a statically variable
$b = $b +1;
Echo $b;
return $b;
}


? $a =&test ();? & Represents a reference function this way, the $b and $ A returned by test () point to the same address. It can also be said that $ A is $b. Modify any one, and the other will change as well. Output here 1

? $a = 5;? Here $a=5, just $b also equals 5. Because the above $a=&test () is the address reference.
? Test (); Because this will output 6.

?

Example 2.

$a = 123;

$b =& $a;

$b = 321;

echo $a;

And the above example is the same, output 321.

  • 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.