Question:medium

What is the purpose of the echo statement in PHP?

Show Hint

In PHP, both `echo` and `print` can be used to display output. `echo` is slightly faster as it is a language construct and doesn't return a value, while `print` is a function that returns 1. `echo` can also take multiple arguments.
Updated On: Jul 2, 2026
  • store data in a database
  • execute JavaScript code
  • display output on a webpage
  • To comment on code
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Remember that PHP runs before the page ever reaches the browser.
PHP is a server-side language, meaning its code executes on the web server first, and whatever it produces is then sent to the visitor's browser as the final HTML page.
Step 2: See how echo fits into that process.
The echo statement is PHP's basic tool for sending text, variables, or expression results out into that HTML page, so a line like echo followed by a heading tag and some text makes those words appear as a heading once the page loads in the browser.
Step 3: Rule out the unrelated options.
Storing data needs separate database functions, executing JavaScript is the browser's job once it actually receives that code, and comments in PHP use different symbols entirely, so none of those describe what echo does, confirming that its role is simply to display output on the webpage.
\[ \boxed{\text{display output on a webpage}} \]
Was this answer helpful?
0