Bird
0
0

What will be the output of the following PHP code?

medium📝 Predict Output Q13 of 15
PHP - Basics and Execution Model
What will be the output of the following PHP code?
<?php
// echo 'Hello';
echo 'World';
?>
AHelloWorld
BNo output
CHello
DWorld
Step-by-Step Solution
Solution:
  1. Step 1: Understand the effect of the comment

    The line // echo 'Hello'; is commented out, so it does not run.
  2. Step 2: Identify the executed code

    The line echo 'World'; runs and prints "World".
  3. Final Answer:

    World -> Option D
  4. Quick Check:

    Commented out code does not run, so output = World [OK]
Quick Trick: Code after // is ignored, only uncommented code runs [OK]
Common Mistakes:
  • Thinking commented code runs
  • Confusing output by combining commented and uncommented lines
  • Ignoring that echo prints text

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes