<?PHPclassTalker {Private $data= ' Hi '; Public function& Get () {//The return value points to a content, here is the content that points to $data,//test: If the function name is not preceded by &, the code executed below final output: Hihihihi return $this-data; } Public functionout () {Echo $this-data; } } $aa=Newtalker (); $aa-out (); $b= &$aa->get ();//this actually points to the contents of the $data, changing the value of the $d to change the contents of the $data $b= ' How '; $aa-out (); $b= ' is '; $aa-out (); $b= ' You '; $aa-out (); $b= ' Hi '; Echo' <br/> '; //convert $b to arrays, foreach Loop output $arr=Array(' How ', ' is ', ' you '); $aa-out (); $value= &$aa->get ();//point $value to the contents of $data foreach($arr as $value) { $value=Strtoupper($value); $aa-out (); }unset($value);//finally best to unbind?>
PHP Reference (&) exercises