What are the potential pitfalls of using recursive functions to check if a number is even or odd in PHP?

One potential pitfall of using recursive functions to check if a number is even or odd in PHP is the risk of encountering a "maximum function nesting level reached" error if the recursion goes too deep. This can happen if the input number is extremely large. To solve this issue, you can implement a non-recursive function that iterates through the number until it reaches 0 or 1, thus avoiding the risk of hitting the maximum function nesting level.

function isEven($num) {
    while ($num >= 2) {
        $num -= 2;
    }
    return $num == 0;
}

// Test the function
$num = 10;
if (isEven($num)) {
    echo $num . " is even.";
} else {
    echo $num . " is odd.";
}