PHP Method for referencing local static variables of operations and external operation functions

Source: Internet
Author: User

PHP Method for referencing local static variables of operations and external operation functions

Static variables in external operation functions or member methods by reference

The following is a simple example to illustrate three references:

1. type conversion in the function after parameter reference is also an address operation

2. If the parameter is referenced and passed to another function, you must add a reference character to maintain the address operation.

3. The reference operator must be added when the function is declared and called.


This example uses Object method operations and is also applicable to functions.

 Test2 ($ a); $ I ++; var_dump ($ a); var_dump ($ I); return $ I;} protected function test2 (& $) {$ a ['name'] = 'snail ';}}$ obj = new A (); $ a = ''; $ c = & $ obj-> test1 ($ a); $ c ++; var_dump ($ a); $ obj-> test1 ($ ); var_dump ($ );


Output result







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.