1, recursion: In the function of the body directly or indirectly call themselves.
The tedious and repetitive calling program in the refiner, and performs some more complex operation actions.
<?php
/**
* @author blog.anchen8.net
* @copyright 2014
*
*
* Declare a function named test for testing recursion
* $param int $n requires an integer as a parameter
*
*
*
*/
function test ($n) {//declares an argument named Test that has a parameter
echo $n. " "; Outputs the function's value and two spaces at the beginning of a function
if ($n >0) {//Determine if the parameter is greater than 0
Test ($n-1); Call yourself if the parameter is greater than 0, and pass the parameter minus 1 again
} else {//Determine if the parameter is not greater than 0
echo "<-->"; Output delimited string
echo $n. " "; Output parameter values and two spaces at the end of a function
}
echo $n. " "; Output parameter values and two spaces at the end of a function
}
Test (10); Call the test function integer 10 to the parameter
?>
Results: 9 8 7 6 5 4 3 2 1 0 <-->0 1 2 3 4 5 6 7 8 9 10
Still don't understand .....