P

Parvesh Kanani • 2.84K Points
Extraordinary

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

Code:
<?php
$p = 5;
$q = 6;
if (++$p == $q++)
{
    echo "true ", $q, $p;
}
?>
  • (A) true
  • (B) 7
  • (C) 6
  • (D) true 76
  • Correct Answer - Option(D)
  • Views: 106
  • Filed under category PHP

Explanation by: Parvesh Kanani
p is preincremented and q is post incremented thus both are 6 in the if condition, later q is increment.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics