1. Which one of the following is the right way of defining a function in PHP?
2. Type Hinting was introduced in which version of PHP?
3. What will happen in this function call?
<?php
function calc($price, $tax)
{
$total = $price + $tax;
}
$pricetag = 15;
$taxtag = 3;
calc($pricetag, $taxtag);
?>
<?php
function calc($price, $tax)
{
$total = $price + $tax;
}
$pricetag = 15;
$taxtag = 3;
calc($pricetag, $taxtag);
?>
4. 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);
?>
5. Which of the following are valid function names?
1. function()
2. €()
3. .function()
4. $function()
Read More Section(Functions)
Each Section contains maximum 70 questions. To get more questions visit other sections.