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

Code:
<?php
$t = 5;
if ($t-- == ++$t)
{
    echo $t;
}
?>
  • (A) Error
  • (B) 0
  • (C) Nothing
  • (D) 5
πŸ’¬ Discuss
βœ… Correct Answer: (D) 5
Explanation: First $t = 5 is compared to and then decremented, then incremented and compared to $t = 5.
Explanation by: Parvesh Kanani
First $t = 5 is compared to and then decremented, then incremented and compared to $t = 5.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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