Can anyone please explain a recursive function to me in PHP (without using Fibonacci) in layman language and using examples? i was looking at an example but the Fibonacci to
Best explanation I have found when I was learning that myself is here:http://www.elated.com/articles/php-recursive-functions/
Its because one thing:
The function when its called is created in memory (new instance is created)
So the recursive function IS NOT CALLLING ITSELF, but its calling other instance - so its not one function in memory doing some magic. Its couple of instances in memory which are returning themselves some values - and this behavior is the same when for example function a is calling function b. You have two instances as well as if recursive function called new instance of itself.
Try draw memory with instances on paper - it will make sense.