Are there any potential pitfalls to be aware of when using optional parameters in PHP functions?

One potential pitfall when using optional parameters in PHP functions is that if the optional parameter is not provided by the caller, it will default to a specific value, which may not be the intended behavior. To solve this issue, you can check if the optional parameter is set before using it in the function.

function exampleFunction($requiredParam, $optionalParam = null) {
    if(isset($optionalParam)) {
        // do something with optionalParam
    } else {
        // handle case when optionalParam is not provided
    }
}

// Usage
exampleFunction('required value');