Programmer-Add a php udf to the front & why is the effect the same? All the code above

Source: Internet
Author: User
$ A & #039; wap & #039; $ B & #039; kkk & #039; {code...} $ a = 'wap ';
$ B = 'kkk ';

Function sum ($ p) {return $ p. = 'aaa';} function & sum2 ($ p) {return $ p. = 'bbb ';} echo sum ($ a); echo"
"; Echo sum2 ($ B );

Reply content:

$ A = 'wap ';
$ B = 'kkk ';

Function sum ($ p) {return $ p. = 'aaa';} function & sum2 ($ p) {return $ p. = 'bbb ';} echo sum ($ a); echo"
"; Echo sum2 ($ B );

I have answered your related questions in another question. In this example, if you want to compare them, you can change the code:

$ A = 'wap '; $ B = 'kkk'; function sum ($ p) {return $ p. = 'aaa';} function & sum2 (& $ p) {return $ p. = 'bbb ';} // since the reference is returned, it cannot be passed using the form parameter, so change $ p to & $ p echo sum ($ ); // output is wapaaa echo"
"; Echo sum2 ($ B); // output is kkkkbbb echo"
"; Echo sum ($ a); // output is wapaaa echo"
"; Echo sum2 ($ B); // output is kkkkbbbbbb

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.