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 defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
Indicate the PHP variable that contains data added in URL address after the "?" character.
if(isset($_GET["id"])) {
  echo $_GET["id"];
Recursive Functions in PHP

Last accessed pages

  1. Ajax Voting Script - Vote Up Down (6149)
  2. Common PHP Errors and Solutions (6867)
  3. Get visitor IP in PHP (842)
  4. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (43359)
  5. SSEP - Site Search Engine PHP-Ajax (7095)

Popular pages this month

  1. Insert, Select and Update NULL value in MySQL (697)
  2. Read Excel file data in PHP - PhpExcelReader (625)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (394)
  4. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (347)
  5. PHP getElementById and getElementsByTagName (311)