Examveda
Examveda

What will be the output of the following PHP code?

<?php
$op2 = "blabla";
function foo($op1)
{
        echo $op1;
        echo $op2;
}
foo("hello");
?>

A. helloblabla

B. error

C. hello

D. helloblablablabla

Answer: Option C

Solution(By Examveda Team)

If you want to put some variables in function that was not passed by it, you must use “global”. Inside the function type global $op2.

This Question Belongs to PHP >> Functions

Join The Discussion

Related Questions on Functions