Concept

What happens when optional PHP function parameters are omitted?

ComputerScienceOne / Optional & Default Parameters

"Parameters in PHP functions are optional. You can invoke a function without providing a subset of parameters. However, if a parameter is not provided, PHP will treat the parameter as null. If we invoked the getDistance() function with only two parameters: getDistance(10.0, 20.0); then inside the function, $x1 and $y1 would take on the values 10 and 20, but $x2 and $y2 would be null. When used in the distance formula calculations, both would be treated as zero. If we had invoked the function with no arguments, getDistance(); then all four parameters would be treated as null (and thus zero in the calculations)."

Related Ideas

What happens when optional PHP function parameters are omitted? | ComputerScienceOne | Bifalgorithm | Bifalgorithm