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

// 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. Sending data with GET and POST in the same request (5969)
  2. PHP-MySQL Scripts (6021)
  3. PHP Unzipper - Extract Zip, Rar Archives (9552)
  4. Display data from PHP Array, or MySQL in HTML table (20912)
  5. Get the value of the selected /checked checkboxes in a form (43397)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (509)
  2. PHP Unzipper - Extract Zip, Rar Archives (490)
  3. querySelector and querySelectorAll (386)
  4. SHA256 Encrypt hash in JavaScript (379)
  5. Create simple Website with PHP (352)