"Pass-through" and "pass-through" learning notes for PHP custom functions

Source: Internet
Author: User

The transfer of parameters can be divided into two types of transmission value and address, what is the difference?

12345678910 function fun($num1,$num2){$num1=100;$num2=1000;}$n1=1;$n2=10;fun($n1,$n2);echo “n1={$n1} n2={$n2}”;?>

The result is: N1=1 n2=10

This section of code is the process of passing values, custom function fun parameters pass specific $n1, $n 2 value, this is easy to understand, I said before the custom function is a value, then what is the address?

12345678910 function fun($num1,&$num2){$num1=100;$num2=1000;}$n1=1;$n2=10;fun($n1,$n2);echo “n1={$n1} n2={$n2}”;?>

This code, N1 is still the value of the pass, and N2 is the address. What difference does it have? That's right.. is in the function of the parameters of a "&" take the address, meaning is to pass the memory address to the parameter, which is equal to $num2=& $n 2, the result is n3=1 n4=1000.

Alternative asset allocation rise gold ETF Link Fund intensive release: http://licai.daiyuline.com/jijin/313.html

Crude oil market dismal Exxon Mobil's first downgrade in 86 years: http://licai.daiyuline.com/yyjg/312.html

"Pass-through" and "pass-through" learning notes for PHP custom functions

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.