?
What will be the output of the following PHP code ?
What will be the output of the following PHP code ?
<?php
function fun()
{
static $x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>
<?php
function fun()
{
static $x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>
Answer & Solution
Correct Answer:
Option
A
When static is used, each time the function is called, that variable will still have the information it contained from the last time the function was called.
Join the Discussion
Login to post a comment or share your explanation.
Login