?
What will be the output of the following code?
What will be the output of the following code?
<?php
function track()
{
static $count = 0;
$count++;
echo $count;
}
track();
track();
track();
?>
<?php
function track()
{
static $count = 0;
$count++;
echo $count;
}
track();
track();
track();
?>
Answer & Solution
Correct Answer:
Option
A
Because $count is static, it retains its previous value each time the function is executed.
Join the Discussion
Login to post a comment or share your explanation.
Login