Examveda
Examveda

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;
?>

A. 5

B. 10

C. 15

D. Error

Answer: Option C

Solution(By Examveda Team)

You can access the global variable using $GLOBALS[‘globalvariablename’].

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

Join The Discussion

Related Questions on Operators and Expressions in php