A

Admin • 832.27K Points
Coach

Q. What will be the output of the following PHP code ?

Code:
<?php
$num = 2;
while ($num < 5)
{
print "Hello";
$num--;
}
print "World";
?>
  • (A) Error
  • (B) World.......infinite time
  • (C) Nothing
  • (D) Hello......infinite time
  • Correct Answer - Option(D)
  • Views: 22
  • Filed under category PHP
  • Hashtags:

Explanation by: Admin

Since the value of $num will always be less than 5 so while loop will never end.
It will print hello for infinite times .

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.