What potential pitfalls should be avoided when setting default values for method parameters in PHP?

When setting default values for method parameters in PHP, it's important to avoid using mutable data types like arrays or objects as default values. This is because PHP evaluates default parameter values at compile time, meaning that any changes made to mutable default values will affect all subsequent calls to the method. To avoid this pitfall, it's recommended to use immutable data types like strings or integers as default parameter values.

// Avoid using mutable data types as default parameter values
function exampleFunction($array = []) {
    // Do something with $array
}

// Instead, use immutable data types as default parameter values
function exampleFunction($string = '') {
    // Do something with $string
}