Create a function with optional arguments in PHP
Description
The following code shows how to create a function with optional arguments.
Example
<?php/* w w w . j a v a 2 s.co m*/
function calcSalesTax($price, $tax="")
{
$total = $price + ($price * $tax);
echo "Total cost: $total";
}
calcSalesTax(42.00);
?>
The code above generates the following result.