A

Admin • 825.56K Points
Coach

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

Code:
<?php
$n = 1;
while(++$n || --$n)
{
print $n;
}
?>
  • (A) 2345678......infinite time
  • (B) 12345678...........infinite time
  • (C) Error
  • (D) Nothing
  • Correct Answer - Option(A)
  • Views: 4
  • Filed under category PHP
  • Hashtags:

Explanation by: Admin
As it is || operator the second expression is not evaluated and n is always incremented, in the first case to 1.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.