Php & Application

Source: Internet
Author: User
Example of an & amp; application in php :? $ A = 1; $ B = & amp; $ a; $ B = 2; echo $ B; // 2 echo $ a; // 2? 1 indicates that a reference is passed to the function. If you really want to use references to pass. You need functiona (& amp; $ obj) {} to accept it. However, it is not recommended that 2 be used to transfer & Applications in php

Example:

?

$ A = 1; $ B = & $ a; $ B = 2; echo $ B; // 2 echo $ a; // 2

? 1

Indicates that a reference is passed to the function. If you really want to use references to pass. You need function a (& $ obj) {} to accept it. However, 2 is not recommended to indicate that a variable is passed. It is only a reference message for receiving. Not recommended. Description in the manual. Php4.1, it seems that from this version, php introduced the variable count function. There is no additional memory expenditure for variable transfer. In addition, the reference transfer requires another reference count, so it is not recommended to pass the reference. if the variable is not very large, it is recommended to use the pass value instead of reference. Starting from php5. All Obj values are passed by reference. No matter whether & = and & = are used for Obj operations, a warning message is displayed. Therefore, it is usually easier to pass references without passing references.
& Indicates that address transfer saves memory when you need to operate on big data, when multiple function return values are required, you can also reference passing parameters. I found an article on the internet for you to see, which should help you understand.
Reference: http://blog.sina.com.cn/s/blog_4f9fc6e10100av1p.html
A pointer can be a memory address or a value in the memory address. a reference refers to two variables pointing to the same memory, that is, the names are different.

?

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.