What are the best practices for implementing a function that calls itself in PHP without causing an infinite loop?

When implementing a function that calls itself in PHP, it's important to have a base case that will eventually stop the recursion to prevent an infinite loop. This base case should be a condition that will be met at some point during the recursion. Additionally, make sure to pass different arguments to the recursive calls to ensure progress towards the base case.

function recursiveFunction($n) {
    // Base case
    if ($n <= 0) {
        return;
    }
    
    // Recursive call with different argument
    recursiveFunction($n - 1);
    
    // Other logic here
}

// Start the recursion
recursiveFunction(5);