Function Recursion Demo : Function Recursion « Functions « PHP






Function Recursion Demo

<html>
<head>
<title>Recursion</title>
</head>
<body>
<?php
     function cnt_backwards($from) {
          $from--;
          if($from <= 1) {
               print($from);
               return;
          }
          print($from);
          cnt_backwards($from);
     }
     cnt_backwards(5);
?>
</body>
</html>
           
       








Related examples in the same category

1.Define recursive function to delete directories
2.A recursive function is a function that calls itself from within its own code.
3.Using a recursive function to sum an integer set
4.Recursive Function Example
5.Recursive Functions