?
What will be the output of the following PHP code ?
What will be the output of the following PHP code ?
<?php
function fun()
{
$x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>
<?php
function fun()
{
$x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>
Answer & Solution
Correct Answer:
Option
C
Every time the function is called the value of x becomes 0, therefore we get 0 on every function call.
Join the Discussion
Login to post a comment or share your explanation.
Login