ExamVeda
Login
Home
This question belongs to PHP Functions
Functions
?

What will be the output of the following PHP code?
<?php
function calc($price, $tax="")
{
    $total = $price + ($price * $tax);
    echo "$total"; 
}
calc(42);	
?>

Answer & Solution
Correct Answer: Option C
You can designate certain arguments as optional by placing them at the end of the list and assigning them a default value of nothing.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Anil Dadhich
Anil Dadhich 7 years ago
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.