What will be the output of the following PHP code ?
<?php
function TV($string)
{
echo "my favourite TV show is ".$string;
function b()
{
echo " I am here to spoil this code";
}
}
function b()
{
echo " I am here to spoil this code";
}
b();
?>
<?php
function TV($string)
{
echo "my favourite TV show is ".$string;
function b()
{
echo " I am here to spoil this code";
}
}
function b()
{
echo " I am here to spoil this code";
}
b();
?>
A. I am here to spoil this code
B. Error
C. my favourite TV show isI am here to spoil this code
D. None of the mentioned
Answer: Option A
Solution(By Examveda Team)
This one works because b is declared independent of TV() also.Related Questions on Functions
Which one of the following is the right way of defining a function in PHP?
A. function { function body }
B. data type functionName(parameters) { function body }
C. functionName(parameters) { function body }
D. function fumctionName(parameters) { function body }
A. Call By Value
B. Call By Reference
C. Default Argument Value
D. Type Hinting
Join The Discussion