What is the purpose of using "optional" parameters in PHP functions?

Using "optional" parameters in PHP functions allows for flexibility in function usage by allowing certain parameters to be omitted when calling the function. This can be useful when there are certain parameters that are not always necessary for the function to execute properly. By setting these parameters as optional, it gives the user the choice to include them or not, making the function more versatile.

function greet($name, $greeting = "Hello") {
    echo $greeting . ", " . $name;
}

// Calling the function with both parameters
greet("John", "Good morning");

// Calling the function with only the required parameter
greet("Jane");