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 HTML5 tag can be used to embed an external application (SWF, PDF) in web page?
<mark> <embed> <canvas>
<embed src="flash_game.swf" width="450" height="350" />
Which CSS pseudo-element adds a special style to the first line of a text?
:first-letter :before :first-line
#id:first-line {
  font-weight: bold;
  color: blue;
}
Click on the window object property which gets or sets the URL of current page.
window.location window.self window.status
var url = window.location;
alert(url);
Indicate the PHP function used to get the contents of a file or page and store it into a string.
fopen() file_put_contents() file_get_contents()
$homepage = file_get_contents("http://coursesweb.net/");
echo $homepage;
Recursive Functions in PHP

Last accessed pages

  1. Node.js Course (2790)
  2. html2canvas - Save page screenshoot on server (4963)
  3. Get Duration of Audio /Video file before Upload (15422)
  4. PHP Method Chaining (5451)
  5. Chaining Static and Public Methods in PHP (2981)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (318)
  2. CSS cursor property - Custom Cursors (56)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (44)
  4. The Mastery of Love (41)
  5. CSS3 2D transforms (40)