freeCodeCamp/guide/english/php/functions/echo-and-print/index.md

1.1 KiB

title
Echo and Print

Echo and Print

The echo and print functions provide a way to write out the value of a variable or argument to the screen.

echo

The echo() function writes out the value of a variable or argument to the screen.

<?php
echo "freeCodeCamp";

NOTE: A short hand way to open the PHP tag and echo is <?=

<?= "freeCodeCamp"; ?>

print

The print() function out the value of a variable or argument to the screen.

<?php
print "freeCodeCamp";

print_r

The print_r() function writes out the value of any variable (such as an array) or argument to the screen, unlike the echo or print functions which are more limited.

<?php
$freecodecamp = "freeCodeCamp";
print_r($freecodecamp);

More Information: