PHP variable Usage

Source: Internet
Author: User

Common variables:

$name = "10";

Variable variable:

1)

$a = "10"; From the first line, assign 10 to $ A;

$b = "20"; The second line, said to give 20 to $b;

$a = $b; The third line, the value of the variable $b is assigned to $ A;

Output, you can see that the value of $ A has changed to 20.

2)

$a = "10"; From the first line, assign 10 to $ A;

$a = $b;  The second line indicates that the value of the $b is assigned to $ A. This is because the previous line does not give $b value, so the value of $ A is unknown, the program executes to this line, the value of $a has been set to unknown, is no longer 10

$b = "20";  In the third line, the 20 is assigned to the $b. Since the program does not go back, the value of $ A will not change at this time.

Output $ A and $b, you can see a $ A output is blank, no data ...

As can be seen above, PHP implementation is very strict!

Reference variable:

$a = "10"; Assigns 10 to the variable $ A

$a =& $b; Represents $ A Gets the address to $b. The address of $ A now is the same as the address of $b

$b = "50"; To assign 50 to $b.

The output shows that both the $a and $b values are 50

PHP variable Usage

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.