PHP – Echo – Print

echo -> can output one or more strings, echo does not return any value.

print -> can only output one string, and returns always 1.


<?php

// echo of Strings
// ------------------
echo "<h2>PHP with HTML tags inside</h2>";
echo "This", " string", " was", " made", " with multiple parameters.";

// echo of variables
// ------------------
$txt1="I like PHP";
$txt2="blog.lucedigitale.com";
$cars=array("Volvo","BMW","Toyota");

echo $txt1;
echo "<br>";
echo "Study PHP at $txt2";
echo "My car is a {$cars[0]}";

// print of Strings
// ------------------
print "<h2>PHP is fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!";


// print of variables
// ------------------
$txt1="I like PHP";
$txt2="blog.lucedigitale.com";
$cars=array("Volvo","BMW","Toyota");

print $txt1;
print "<br>";
print "Study PHP at $txt2";
print "My car is a {$cars[0]}";

?>