About variable assignment?

Source: Internet
Author: User
Ask like a variable to assign a value

$foo = 25;

If this sentence is executed, is not in memory at the same time open up two storage space Ah one is the storage value of 25, the other $foo is stored in the value of 25 address.

Is this the right thing for me to understand?



Otherwise, if it is to open up a space that unset, the value of 25 should be released AH:
$foo = 25;
$boo =& $foo;
Unset ($boo);
Echo $foo; Output 25



Reply to discussion (solution)

Dude, the quote after PHP5.4 has changed.

$foo =25; $boo = $foo; unset ($boo); Echo $foo; Output 25func (& $var); function func (& $var) {//a series of operations on $var} but after the php5.4 version, the reference passing of the array and the object changed: Func ($var); Notice here that there is no & when calling the function, but there is also function func (& $var) {//a series of operations on $var} when defining

It's like you create a shortcut on the desktop, you delete the shortcut, but the item is still in its original position.

Wait for the Big bird ...

If you are using unset (), and the reference to the variable it references is still there, the memory will not be released for the time being, and only if all of the variables have been disconnected from the memory area, the freed memory area will be released.

If you are using unset (), and the reference to the variable it references is still there, the memory will not be released for the time being, and only if all of the variables have been disconnected from the memory area, the freed memory area will be released.

Thank you for your reply, I just want to know when the PHP parser encountered $foo=25 in memory changes in the situation, you can point it down, thank you

If the object
So $foo save the address of the object
$boo = $foo just copy an address to him.

But the data 25 is only a numeric value, so there's no 25. The object address is directly the value

$boo Store the address of $foo.

This post was last edited by xuzuning on 2013-11-22 14:03:00

The variable management of PHP can be simplified to maintain such a table
  • 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.