What is the difference in output when the echo statement is placed before or after the recursive function call in a PHP function?

Placing the echo statement before the recursive function call will output the current value before the recursive call is made, while placing it after the recursive call will output the current value after the recursive call is completed. To ensure the desired output order, the echo statement should be placed before the recursive function call.

function recursiveFunction($num) {
    echo $num . " "; // Output the current value before the recursive call
    
    if ($num > 0) {
        recursiveFunction($num - 1);
    }
}

// Call the recursive function
recursiveFunction(5);