PHP allows you to define C++ style default argument values. In such case, if you don't pass any value to the function, it will use default argument value.
Let' see the simple example of using PHP default arguments in function.
<?php
function sayHello($name="Ram"){
echo "Hello $name";
}
sayHello("Sonoo");
sayHello();//passing no value
sayHello("Vimal");
?>Output:
Output:
<?php
function add($n1=10,$n2=10){
$n3=$n1+$n2;
echo "Addition is: $n3";
}
add();
add(20);
add(40,40);
?>Output:
