Create a “Hello World” program in PHP

Advertisement

Are you a beginner? And want to learn about how to create a hello world program in PHP?

Then you are in the right place.

You are going to see:

Start and End Tags in PHP Start and End Tags in PHP

To execute the PHP code we need to use the PHP start and end code.

To start the PHP code you need to use <?php

And its ends with ?>

Every code within the <?php and ?> will execute.

E.g.

<?php
     // PHP code goes here.
?>

Top ↑

Example of “Hello World” program Example of “Hello World” program

Follow below Hello World code sample:

<?php
     echo 'Hello World';
?>

When you execute the PHP code then you’ll see the “Hello World” text.

Note: Here we have used the echo keyword which is used to print the text.

You can use it with print() as:

<?php
     print( 'Hello World' );
?>

Or you may use the print_r() as:

<?php
     print_r( 'Hello World' );
?>
%d bloggers like this: