Are there best practices for implementing recursion in PHP?

When implementing recursion in PHP, it is important to consider the base case to prevent infinite recursion. Additionally, it is essential to pass updated parameters to the recursive function to make progress towards the base case. Lastly, ensure that the recursive function returns the final result correctly.

function factorial($n) {
    if ($n <= 1) {
        return 1;
    } else {
        return $n * factorial($n - 1);
    }
}

echo factorial(5); // Output: 120