Hello World
Explore the classic Hello World program in PHP to understand how to display text output using echo and print functions. This lesson helps you get familiar with basic PHP syntax and prepare for more advanced programming concepts.
We'll cover the following...
Why “Hello World”?
The first program that most aspiring programmers write is the classic “Hello World” program. The purpose of this program is to display the text “Hello World!” to the user.
The “Hello World” example is somewhat famous as it is often the first program presented when introducing a programming language.
Syntax #
Try running the code below:
The most widely used language construct to print output in PHP is echo.
Alternatively, you can also use print:
PHP also provides C-style printf and related functions. Run the following code:
Now in the next lesson, we will discuss the syntax of the “Hello World!” code in detail to get you familiarized with the basic syntax in PHP.