From the below code can anyone explain me why the value of the variable "$value" is returned as 56 in both echo's and not as 101 and 1001??
Because the first time you call your function you use '&increment()' and the second time you use 'increment()'. I'm not sure it's technically legal to have a function name that starts with an '&'. You might consider changing the function name to make things simpler.
You are incorrectly trying to call the function by reference which will not work..... you might want to check here for details on how - and when - you might want to do that. http://www.php.net/manual/en/language.references.pass.php Also, you are not storing the returned value before echoing it..... $value=increment(100); print "$value<br />"; $value=increment(1000); print "$value<br />"; PHP: output: 101<br />1001<br />