Examveda
Examveda

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

A. 43

B. 943

C. 349

D. 439

Answer: Option D

Solution(By Examveda Team)

Firstly, the statements outside the function are printed, since z is not defined it’ll no value is printed for z. Next the function is called and the value of z inside the function is printed.

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

Join The Discussion

Related Questions on Operators and Expressions in php