Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

PHP Default Argument Value

The following example demonstrates how to use a default parameter. If we call the function setHeight() without any arguments, it will use the default value as the argument

Example

function setHeight($minheight = 50) {
  echo "The height is : $minheight <br>";
}
 
setHeight(350);
setHeight(); // will use the default value of 50
setHeight(135);
setHeight(80);