Skip to content
doubtly

2 answers

echo is a PHP language construct (not a function) used to output one or more strings; it returns no value.

<?php
$name = "Riya";
echo "Hello";                 // one string
echo "Hello ", $name, "!";    // several strings, separated by commas
echo("Hello");                // parentheses allowed with ONE argument
?>

Key points:

  • Since echo is a language construct, parentheses are not needed.
  • It can take several comma-separated arguments, but then you must not put parentheses around them: echo("a", "b"); is a parse error.
  • echo has no return value, so it cannot be used inside an expression. (print, by contrast, takes one argument and returns 1.)
  • A short form <?= $name ?> is the same as <?php echo $name; ?>.
Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.