J

Jitendra Singh • 7.50K Points
Tutor III

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: 132
  • Filed under category PHP

Explanation by: Jitendra Singh
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.


Question analytics