mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-11-25 15:17:24 +08:00
* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
679 B
679 B
Default / Optional Params
In PHP, you can assign default values to your function parameters. These are called default or optional parameters. This is exceptionally useful when you want to make the function argument optional so if a value is not provided when the function is called, then the default value is used instead. Here's a simple code example:
function greet($name = "guest") {
echo "Hello, $name!";
}
greet(); // Outputs: Hello, guest!
greet("John"); // Outputs: Hello, John!
Visit the following resources to learn more: