How can PHP functions be structured to allow for optional parameters without affecting the function's functionality?
To allow for optional parameters in PHP functions without affecting the function's functionality, you can use default parameter values. By setting default values for parameters, you can call the function without providing those parameters, and the function will use the default values instead.
function greet($name, $age = 30) {
echo "Hello, $name! You are $age years old.";
}
// Calling the function with both parameters
greet("Alice", 25);
// Calling the function with only one parameter
greet("Bob");