Home »
MCQs »
PHP MCQs
What will be the output of the following PHP code (3)?
24. What will be the output of the following PHP code?
<?php
function Increment(){
static $num = 0;
echo "$num";
$num++;
}
Increment();
Increment();
Increment();
?>
- 000
- 111
- 011
- 012
Answer: D) 012
Explanation:
In the above code, $num is a static variable and it will be initialized once. Thus, the output would be "012".