Variable assignment?

Source: Internet
Author: User
Variable assignment? Assign a value to a variable.

$ Foo = 25;

If this statement is executed, are two buckets in the memory? one is the storage value 25, and the other is the address with the value 25.

Is my understanding as follows correct?



Otherwise, the value of 25 should be released when unset is used to open up a space:
$ Foo = 25;
$ Boo = & $ foo;
Unset ($ boo );
Echo $ foo; // output 25



Reply to discussion (solution)

Buddy, the reference section after PHP5.4 has changed

$ Foo = 25; $ boo = $ foo; unset ($ boo); echo $ foo; // output 25 func (& $ var); function func (& $ var) {// A series of operations on $ var}. However, in php5.4 and later versions, the transfer of references to arrays and objects has changed, like this: func ($ var ); // note that the function is no longer called, but function func (& $ var) is also defined {// processing a series of operations on $ var}

This is like creating a shortcut on the desktop. you have deleted the shortcut, but the content is still in the original location.

Wait for the big bird...

If you are using unset (); the reference relationship of the variables referenced by it is still there, the memory will not be released yet, the released memory zone will be released only when all variables are disconnected from this memory zone.

If you are using unset (); the reference relationship of the variables referenced by it is still there, the memory will not be released yet, the released memory zone will be released only when all variables are disconnected from this memory zone.

Thank you for replying. Hello, I just want to know if the PHP parser has changed $ foo = 25 in the memory. can you give me some advice? thank you!

If it is an object
Then $ foo stores the object address.
$ Boo = $ foo only copies an address to him.

However, data 25 is only a value, so there is no 25. this object address is directly a value.

$ Boo stores the address of $ foo.

This post was last edited by xuzuning at 14:03:00, January 22 ,.

Php variable management 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.