Bird
0
0

Which of the following is the correct way to write a PHP script that outputs "Hello World"?

easy📝 Syntax Q3 of 15
PHP - Basics and Execution Model
Which of the following is the correct way to write a PHP script that outputs "Hello World"?
A<?php echo 'Hello World'"
B<?php echo Hello World; ?>
C<?php echo \"Hello World\" ?>
D<?php echo 'Hello World'; ?>
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax correctness

    uses proper PHP tags, echo statement, quotes around string, and semicolon.
  2. Step 2: Identify errors in other options

    misses quotes around string; misses semicolon;
  3. Final Answer:

    <?php echo 'Hello World'; ?> -> Option D
  4. Quick Check:

    Correct syntax = [OK]
Quick Trick: Always end PHP statements with a semicolon [OK]
Common Mistakes:
  • Forgetting quotes around strings
  • Missing semicolon
  • Not closing PHP tags

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes