<?php function a($n){ b($n); return ($n * $n); } function b[COLOR="Red"](&$n)[/COLOR]{ $n++; } echo a(5); //Outputs 36 ?> Code (markup): What is the use of & in function b
it is passing by reference , which means the function can modify the value. check here for more details : http://php.net/manual/en/language.references.pass.php
Your code is working similar to as if $n is "global" variable. You can also use: function a($n){ $n=b($n); return ($n * $n); } function b($n); ++$n; return $n; } Code (markup): Thanks