How to create default function parameter in PHP? Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The default parameter concept comes from C++ style default argument values, same as in PHP you can provide default parameters so that when a parameter is not passed to the function. Then it is still available within the function with a pre-defined value. This function also can be called optional parameter. Syntax: function greeting($name=" parameter_value ") Parameter: This function accepts a single parameter that is $name here, holds the parameter value. Below examples illustrate the procedure to create and use the default function parameter. Example 1: php <?php function greeting($name="GeeksforGeeks") { echo "Welcome to $name "; echo("\n"); } greeting("Gfg"); // Passing no value greeting(); greeting("A Computer Science Portal"); ?> Output: Welcome to Gfg Welcome to GeeksforGeeks Welcome to A Computer Science Portal Example 2: php <?php function welcome($first="GeeksforGeeks", $last="A Computer Science Portal for Geeks") { echo "Greeting: $first $last"; echo("\n"); } welcome(); welcome("night_fury"); welcome("night_fury","Contributor"); ?> Output: Greeting: GeeksforGeeks A Computer Science Portal for Geeks Greeting: night_fury A Computer Science Portal for Geeks Greeting: night_fury Contributor Comment More info N night_fury1 Follow Improve Article Tags : Web Technologies PHP PHP-basics Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like