PHP Program to print hello world


February 9, 2022, Learn eTutorial
1936

For a better understanding of this example, we always recommend you to learn the basic topics of PHP programming listed below:

A string is a series of characters, where a character is the same as a byte. PHP supports a 256-character set and hence does not offer native Unicode support. 

Php program to print hello world program is a computer program that emits or displays the message “Hello, World!” Such a program is fairly easy in most programming languages, and it is frequently used to teach a programming language’s basic grammar.

Note: As of PHP 7.0.0, there are no particular restrictions regarding the length of a string on 64-bit builds. On 32-bit builds and in earlier versions, a string can be as large as up to 2GB (2147483647 bytes maximum).

A string literal can be specified in four different ways:

  • single-quoted: The simplest way to specify a string is to enclose it in single quotes (the character ').
  • double quoted: The simplest way to specify a string is to enclose it in single quotes (the character ").
  • heredoc syntax: A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline.
  • nowdoc syntax (since PHP 5.3.0): Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc

 

ALGORITHM

STEP 1: Use the echo keyword to display the message.

PHP Source Code

                                          <?php
echo "Hello World!"."\n";
echo "Tomorrow I \'ll learn PHP global variables."."\n"; 
echo "This is a bad command : del c:\\*.*"."\n"; 
?>

                                      

OUTPUT

Hello World!
Tomorrow I \'ll learn PHP global variables.
This is a bad command : del c:\*.*