Welcome to the PHP-scripts blog. Though I’m not a huge fan of ‘Hello World’ stuff, it seems that is where most things in the programming world start out. So here we go with examples using print and echo

Hello World using print statement

<?php
print ‘Hello World!’;
?>

Hello World using echo

<?php
echo ‘Hello World!’;
?>

What is the difference between print and echo? print behaves like a function and can be used in expressions like this, where echo cannot:

$returns = print ‘Hello World’; // $returns = 1
 

echo is a tiny bit faster since it doesn’t set a return value.

Programming tips
Pick one format and stick to it. For example, I like to use echo for echoing variable values like this:

echo($name); // outputs value of string $name
 

But I prefer print for mixing text and variables like this:

$name = ‘TDavid’;
print “My name is: $name”; // outputs: My name is TDavid
 

Since you can use or not use parenthesis, it’s important to determine a style that is consistent throughout coding projects to keep code easy to read.