Need Assistance?

support@tutorialshub.in

Getting Started with PHP

PHP Tags, echo vs print & Comments

ADVERTISEMENT
PHP Free Lesson
5 min read
ADVERTISEMENT

Every PHP block starts with <?php and ends with ?>. If a file contains only PHP code (such as a class or config file), it is best practice to omit the closing ?> tag so accidental trailing spaces never cause "headers already sent" errors.

echo vs print

  • echo — Slightly faster, accepts multiple comma-separated arguments, and has no return value (most commonly used).
  • print — Always returns 1, accepts only one argument.
ADVERTISEMENT
Hi, I'm Tuby! Here to help you