How does the usage of static variables in PHP functions affect performance and memory usage?

Using static variables in PHP functions can impact performance and memory usage because static variables retain their value between function calls, which means they occupy memory for the duration of the script execution. To improve performance and memory usage, consider using function parameters or return values to pass data between function calls instead of relying on static variables.

function calculateSum($num1, $num2) {
    return $num1 + $num2;
}

// Usage
$result = calculateSum(5, 10);
echo $result; // Output: 15