ExamVeda
Login
Home
Operators and Expressions in php
?

What will be the output of the following PHP code ?
<?php
$i = 5;
while (--$i > 0)
{   
    $i++;
    print $i;
    print "hello";
}
?>

Answer & Solution
Correct Answer: Option A
i is decremented in the first while execution and then continuously incremented back.
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Kalam Ahmed
Kalam Ahmed 2 years ago
The output should indeed be 5hello5hello5hello..., not 4hello4hello....
Raham Sher
Raham Sher 6 years ago
Dear its output is option B