Php reference (&)
##### Php reference allows two variables to point to the same content"
"If an undefined variable is referenced and assigned with a reference parameter, the variable" function foo (& $ var) {} foo ($ ); var_dump ($ a); // output null $ B = array (); foo ($ B ['B']); var_dump (array_key_exists ('B ', $ B); // bool true $ c = new stdClass (); foo ($ c-> d); var_dump (property_exists ($ c, 'D ')); // bool true "if a declaration is given a reference to the global variable within a function, the reference is only visible within the function, you can avoid "$ var1 =" example variable "; $ var2 =" "; function global_references ($ use_globals) {global $ var1, $ var2; if (! $ Use_globals) {$ var2 = & $ var1;} else {$ GLOBALS ["var2"] = & $ var1 ;}} global_references (false ); echo "var2 is set to $ var2 "."
"; //" Var2 is set to "global_references (true); echo" var2 is set to $ var2 "."
"; //" Var2 is set to example variable "" when 'unset' is referenced, only the binding between the variable name and the variable content is broken, it does not mean that the content of the variable is destroyed"
"Function Reference transfer" function test (& $ a) {$ a = $ a + 100;} $ B = 1; echo $ B; // output 1 test ($ B); // Here $ B is actually the memory address of the $ B variable content, by changing the value of $ a in the function, you can change the value of $ B by echo $ B; "function reference return"
"The reference structure appears in the object-oriented model." class fucker {private $ data = 'hi'; public function & get () {return $ this-> data;} public function out () {echo $ this-> data ;}}$ q = new fucker (); $ d = & $ q-> get (); $ q-> out (); $ d = 'fuck'; $ q-> out (); $ d = 'u'; $ q-> out (); $ d = 'sir '; $ q-> out (); // hifuckusir"