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