Php-mysql Course

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).

<?php
// 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

HTML
CSS
JavaScript
PHP-MySQL
Which tag adds an image in web page?
<div> <img> <span>
<img src="http://coursesweb.net/imgs/webcourses.gif" width="191" height="63" alt="Courses-Web" />
Which of these CSS codes displays the text oblique?
font-style: italic; text-decoration: underline; font-weight: 500;
#id {
  font-style: italic;
}
Click on the jQuery function used to hide with animation a HTML element.
click() hide() show()
$(document).ready(function() {
  $(".a_class").click(function(){ $(this).hide("slow"); });
});
Click on the correctly defined function in PHP.
fname function() {} function fname() {} function $fname() {};
function fname($a, $b) {
  echo $a * $b;
}
Recursive Functions in PHP

Last accessed pages

  1. ActionScript 3 - Change MovieClip Color (8941)
  2. Select in MySQL, Output results in HTML Table (19331)
  3. Save image on server from external URL (3034)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (68952)
  5. Understanding OOP - Object Oriented Programming (5148)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (320)
  2. Read Excel file data in PHP - PhpExcelReader (117)
  3. The Four Agreements (96)
  4. PHP Unzipper - Extract Zip, Rar Archives (93)
  5. The Mastery of Love (85)
Chat
Chat or leave a message for the other users
Full screenInchide