Examveda
Examveda

What will be the output of the following PHP code?
<?php
function a()  
{
    function b()
    {
       echo 'I am b';
    }
    echo 'I am a';
}
b();
a();
?>

A. I am b

B. I am bI am a

C. Error

D. I am a Error

Answer: Option C

Solution(By Examveda Team)

This will be the output- Fatal error: Call to undefined function b(). You cannot call a function which is inside a function without calling the outside function.

This Question Belongs to PHP >> Functions

Join The Discussion

Related Questions on Functions