Differences between the value types of PHP and C #

Source: Internet
Author: User
The value types of PHP and C # are different. The copy difference between PH and C # values (if not, I hope to point it out !) $ A2; $ B $ a; in php, point B's address to a, so B is equal to 2 at this time. The difference lies in $ a5; at this time, the copy of p PH and C # values is different (if anything is wrong, I hope to point it out !)

$ A = 2;

$ B = $ a; // In php, point B's address to a, so B is equal to 2 at this time. The difference lies in this

$ A = 5; // at this time, php re-writes the value of a, so the php core will re-allocate B to an address, and then copy the original value of. This is the principle of copy during write. that is to say, unless a write operation is performed, the value type points to an address.

C. Value type replication. Always create an address, for example:

Int a = 2;

Int B = a; // whether or not the secondary write of a is performed .. NET will allocate a new memory space to B (the value exists in the stack space ). Then copy the value of.

Note: values of the value type in C # are directly stored in the stack. For the reference type, the reference address is stored in the stack, and the actual value is stored in the heap. Locate the value in the stack based on the stack address.

Else (if something is wrong, I hope to point it out !) $ A = 2; $ B = $ a; // In php, point the address of B to a, so B is equal to 2. The difference is that $ a = 5; // p...

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.