default arguments in php in hindi

Опубликовано: 27 Октябрь 2024
на канале: Tarun Sir
126
1

Default argument in the function
In this video, you will learn how to create a function that has a default value for the argument(s).
A function may define default values for arguments using syntax similar to assigning a variable.
The default is used only when the parameter is not specified.
If you pass null as the parameter then default value is not used.

function bakepizza($size = "medium")
{
return "Making a pizza of $size size.\n";
}
echo bakepizza ();
echo bakepizza(null);
echo bakepizza("small");

The default value must be a constant expression, not (for example) a variable, a class member or a function call.

Note that any optional arguments should be specified after any required arguments, otherwise they cannot be omitted from calls.
Consider the following example:


function makerayta($quantity = 2, $type)
{ return "Making a $quantity plates of $type rayta.";
}

echo makerayta("veg tadka");


www.tarunsir.com
www.cinstitute.co.in

Learn C Language from beginning
   • C Language tutorial complete  

Learn C++ from beginning
   • C++ tutorial in hindi  

Learn Java from beginning
   • Java tutorial in hindi  

Learn Python from beginning
   • Python full course  

Learn PHP from beginning
   • PHP tutorial  

Connect me on linkedin   / tarrunverrma  
  / the_ultimate_coding_stuff  

#tarunsir #phptutorial #learnprogramming #php #function #functions