Examveda
Examveda

What will be the output of the following PHP code ?
<?php
function fun($x,$y)
{
    $x = 4;
    $y = 3;
    $z = $x + $y / $y + $x;
    echo "$z";
}
fun(3, 4); 
?>

A. 7

B. 9

C. 0

D. Error

Answer: Option B

Solution(By Examveda Team)

Value 3, 4 is passed to the function but that is lost because x and y are initialised to 4 and 3 inside the function. Therefore we get the given result.

This Question Belongs to PHP >> Operators And Expressions In Php

Join The Discussion

Related Questions on Operators and Expressions in php