What will be the output of the following PHP code?
<?php
function calc($price, $tax="")
{
$total = $price + ($price * $tax);
echo "$total";
}
calc(42);
?>
<?php
function calc($price, $tax="")
{
$total = $price + ($price * $tax);
echo "$total";
}
calc(42);
?>
A. Error
C. 42
D. 84
Answer: Option C
Sir i think 42 is wrong answer because you pass $tax as string in function, so how we can multiply a number with a string.