Thuta Learning
BasicProgrammingbeginner

Echo & Print

Relax. We'll talk through this in plain words — no textbook voice.

echo and print are both used to output content. In practice, echo is used far more often. print does have a return value of 1, so it can be used as an expression. As a beginner, though, just remember echo as your go-to for output and you're set.

php
<?php
$course = "PHP";
$platform = "ThutaTech";

echo "<h2>Learn " . $course . "</h2>";
print "Practice with " . $platform . "<br>";
?>
You should see
The heading "Learn PHP" and the text "Practice with ThutaTech" appear.

Easy traps

  • Forgetting the dot . when concatenating strings will cause a syntax error.
Echo & Print | Thuta Learning