Recursive Functions are functions that auto-call themself. Generally, a recursive function returns a value that are passed as argument, so the value is passed from an auto-call to the other, until it is returned.
Recursive functions are very useful in equations with factorial numbers and some operatios with multi-dimensional array.
Factorials are written like 6! and this means: 6 * 5 * 4 * 3 * 2 * 1. So 6! is 4320 and 4! is 24.
In the fallowing example we have a recursive function that finds the factorial of a number "$nr" (here 8).

// this function auto-calls itself (decrementing $nr) until $nr is 0
function factorial($nr) {
 if($nr > 0) $re = $nr * factorial($nr-1);
 else if($nr == 0) $re = 1;

 return $re;

echo '8 factorial is: '. factorial(8); // 8 factorial is: 45360

- To see another example, visit this page: Get all the unique numbers from two-dimensional array.

Daily Test with Code Example

Which tag adds a new line into a paragraph?
<b> <br> <p>
First line ...<br>
Other line...
Which CSS property can be used to add space between letters?
text-size word-spacing letter-spacing
#id {
  letter-spacing: 2px;
What JavaScript function can be used to get access to HTML element with a specified ID?
getElementById() getElementsByTagName() createElement()
var elm = document.getElementById("theID");
var content = elm.innerHTML;
Click on the "echo" correct instruction.
echo "" echo ""; echo """;
echo "Address URL:";
Recursive Functions in PHP

Last accessed pages

  1. Drag Racer V3 (33769)
  2. Bubble Hit (2851)
  3. Bubbles3 (51669)
  4. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (5885)
  5. Styling link buttons using a Single Image and CSS (1655)

Popular pages this month

  1. Qwop (4067)
  2. Flash Games - Free online Games (2085)
  3. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (1835)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (1792)
  5. Drag Racer V3 (1761)