A static variable inside an external manipulation function or member method by means of a reference
Here is a simple example of three questions about quoting:
1. A type conversion within a function after a parameter reference is also an address operation
2. Once the parameter is referenced and passed to another function, the reference must be added again to maintain the address operation
3. Function return value reference must add Reference operator at function declaration and call
This example uses the action of the object method, and the same applies to the function
<?phpclass A {public Function & Test1 (& $a) {static $i = 0;var_dump ($i), $a = (array) $a; $a [' domain '] = ' http:// Blog.csdn.net/zhouzme '; $this->test2 ($a); $i ++;var_dump ($a); Var_dump ($i); return $i;} protected function Test2 (& $a) {$a [' name '] = ' snail ';}} $obj = new A (); $a = "; $c = & $obj->test1 ($a); $c ++;var_dump ($a); $obj->test1 ($a); Var_dump ($a);
Results of the output