0PricingLogin
PHP Academy · Lesson

Echo and Print Output

Output data to the browser using echo and print statements.

Output in PHP

The most common ways to send output to the browser in PHP are echo and print:

  • echo — language construct, outputs one or more strings, no return value
  • print — language construct, outputs a single string, always returns 1
  • Both are not functions — you don't need parentheses

Using echo

echo is the most common output method and is slightly faster than print:

<?php
echo 'Hello, World!';
echo '<br>';
echo 'PHP', ' is', ' great'; // multiple args with comma

$name = 'Alice';
echo "Hello, $name!";  // variable interpolation

All lessons in this course

  1. Declaring Variables in PHP
  2. PHP Data Types Overview
  3. Echo and Print Output
  4. Type Juggling and Type Casting
← Back to PHP Academy