Examveda
Examveda

What will be the output of the following code?
<?php
function track() 
{
	static $count = 0;
	$count++;
	echo $count;
}
track();
track();
track();
?>

A. 123

B. 111

C. 000

D. 011

Answer: Option A

Solution(By Examveda Team)

Because $count is static, it retains its previous value each time the function is executed.

Join The Discussion

Related Questions on Basic PHP