I am new to the concept of recursion. I have created the following example to try and understand recursion. But I am having difficulties and would appreciate your help.
function getX($count){
$count++;
if($count <= 10){
$countTemp = getX($count);
echo $countTemp; //Shouldn't this skipped?
}
return $count;
}
getX(0);
My confusion is that the above function prints 11, 10, 9, 8....1 but shouldn't the code echo $countTemp;
be ignored as the statement above it causes recursion? I might be comparing recursion with looping here.