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
πŸ’¬ Discuss
βœ… Correct Answer: (D) true 76
Explanation: p is preincremented and q is post incremented thus both are 6 in the if condition, later q is increment.
Explanation by: Parvesh Kanani
p is preincremented and q is post incremented thus both are 6 in the if condition, later q is increment.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
262
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Parvesh Kanani
Publisher
πŸ“ˆ
95%
Success Rate