PHP Hello World

This is the first post on my PHP blog, Phppot. I am starting this blog with enthusiasm, love, and confidence. I hope I will add some value to the PHP community.

Following the tradition, let me start with the Hello World program in PHP. The following script displays the sentence “Hello, World!” in the browser. It is a simple code. There are two basic ways of doing this hello world print, and they are using ‘echo’ or ‘print.’

The difference between using ‘echo’ and ‘print’ is,

  • The echo statement prints the arguments passed to it and does not return any value. But the ‘print’ statement prints the argument and returns a value of 1. Since it returns a value, the ‘print’ statement can be used in expressions.
  • The echo statement can take multiple parameters, and the print statement takes only one parameter.

Example Hello World Code using Echo

<?php
echo "Hello, World!";
?>

Example Hello World Code using Print

<?php
print "Hello, World!";
?>

In this context of printing ‘Hello, World!’, both ‘echo’ and ‘print’ are the same.

PHP Hello World Output

Photo of Vincy, PHP developer
Written by Vincy Last updated: July 6, 2023
I'm a PHP developer with 20+ years of experience and a Master's degree in Computer Science. I build and improve production PHP systems for eCommerce, payments, webhooks, and integrations, including legacy upgrades (PHP 5/7 to PHP 8.x).

5 Comments on "PHP Hello World"

Leave a Reply

Your email address will not be published. Required fields are marked *

Explore topics
Need PHP help?