How can optional parameters be implemented in custom PHP functions?

Optional parameters in custom PHP functions can be implemented by assigning default values to the parameters in the function definition. This allows the function to be called with or without certain parameters, as the default values will be used if the parameters are not provided.

function customFunction($param1, $param2 = 'default_value') {
    // Function logic using $param1 and $param2
}

// Call the function with both parameters
customFunction('value1', 'value2');

// Call the function with only the first parameter
customFunction('value1');