Php reference _ PHP Tutorial

Source: Internet
Author: User
Application referenced in php. Application referenced in php; $ aconFuncTest (); this statement will output the value of $ B as 1 $ a5; $ aconFuncTest (); this statement outputs the value of $ B as 2 $ aconFuncTest (). This statement outputs the application referenced in php.
 '; $ A = conFuncTest (); // This statement will output the value of $ B as 1 $ a = 5; $ a = conFuncTest (); // This statement outputs the value of $ B as 2 $ a = & conFuncTest (); // This statement outputs the value of $ B as 3 // at this time, it is equivalent to $ a = & $ B; $ a = 5; // at this time, $ B is $ a's alias $ B = 5; $ a = conFuncTest (); // This statement will output the value of $ B as 6 // (4) object reference, the object reference is also to save space class object {public $ value = 'Hello World'; // If you want to clone, do not clone public function _ clone () {$ this-> value = 'not clone '; }}$ oBject_a = new object; $ oBject_ B = $ oBject_a; // The above is equivalent to $ oBject_ B = & $ oBject_a; echo $ oBject_a-> value; // Here, ABC is output. // modifying the value of object a will affect the value of B, because $ B is a reference of $ a $ oBject_a-> value = 'not hello'; echo $ oBject_ B-> value; // output not hello // If you do not want to affect the value of object a, use the magic method _ clone $ obj2 = clone $ oBject_a; echo $ obj2-> value; // (5) destroy the variable $ a = 11; $ B = & $ a; unset ($ a); // at this time $ B = 11; // equivalent to function quoteTest () {global $ var; // equivalent to $ var = & $ GLOBALS ['var']; unset ($ var); // deletion only deletes the reference, and the referenced content still exists, same as above, this does not mean that the variable content has been destroyed} $ var = 1; quoteTest (); echo $ var; // echo $ wlt = 111; print_r ($ GLOBALS ); unset ($ wlt); print_r ($ GLOBALS );

The application referenced in the http://www.bkjia.com/PHPjc/962646.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/962646.htmlTechArticlephp; $ a = conFuncTest (); // This statement outputs the value of $ B as 1 $ a = 5; $ a = conFuncTest (); // This statement will output the value of $ B as 2 $ a = conFuncTest (); // This statement will output...

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.