How to use Recursion Function in php

PHP

Recursion means calling parent function inside same function is called as the recursion. Recursion is used to get the value from last to first its main example is of factorial.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recursion Functions Examples in PHP</title>
</head>
<body>
<?php
// A simple example with out the parameters

//This way you can create the function and use it as a recursion
//This is n number of recursion created it will never stop
//To stop the function use the variable with the if condition
function login()
{
//You can write what ever you want to write in the function
echo 'Welcome User X.';
//login();
}
//By this way you can call the function and the function inner content will be called as many time as you will call this function
$p=0;
function login1($p)
{
//You can write what ever you want to write in the function
echo 'Welcome User X.';
if($p<5)
{
//this will break the function and it will print the above values 5 times.
$p++;
login1($p);
}

}

login1($p);

?>
</body>
</html>
-->