?
What will be the output of the following PHP code ?
What will be the output of the following PHP code ?
<?php
$x = 5;
function fun()
{
$x = 10;
echo "$x";
}
fun();
echo "$x";
?>
<?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.
Join the Discussion
Login to post a comment or share your explanation.
Login