?
What will be the output of the following PHP code ?
What will be the output of the following PHP code ?
<?php
$x = 5;
$y = 10;
function fun()
{
$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
}
fun();
echo $y;
?>
<?php
$x = 5;
$y = 10;
function fun()
{
$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
}
fun();
echo $y;
?>
Answer & Solution
Correct Answer:
Option
C
You can access the global variable using $GLOBALS[‘globalvariablename’].
Join the Discussion
Login to post a comment or share your explanation.
Login