ExamVeda
Login
Home
Operators and Expressions in php
?

What will be the output of the following PHP code ?
<?php
$x = 5;
function fun()
{
    $x = 10;
    echo "$x";
}
fun();
echo "$x";
?>

Answer & Solution
Correct Answer: Option B
First when the function is called variable x is initialised to 10 so 10 is printed later the global value 5 is printed.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.