A recursive function calls itself.
The following code uses recursive function to output fibonacci numbers.
<?php $iterations = 10;// www. j av a 2 s . c o m function fibonacci($n) { if (($n == 0) || ($n == 1)) return $n; return fibonacci($n-2) + fibonacci($n-1); } for ($i=0; $i <= $iterations; $i++){ echo $i; echo "\n"; echo fibonacci($i); echo "\n"; } ?>