Do You Know How to Write Hello World Program with PHP
In this step, we will learn how to display text with PHP. With echo statement, you can display the text in the browser. You can use echo with text, numbers, and variables.
Other Articles in PHP Basics Section
- Creating a PHP File with PHP info
- Displaying Text with PHP
- Comments with PHP
- PHP Configuration File
- PHP Error Reporting
Quickly Navigate to Other Sections in PHP Tutorials
Here is the simple statement to display this text.
echo "Hello Student";
This statement should be added only to PHP file
We can use echo statement to display numbers also
If the statements are in separate PHP blocks, no need to add the semicolon at end of each statement. If it’s in the same PHP block you should add the semicolon at end of each statement.
You can see the code below
<?php echo "Hello World" //semicolon not required, best parctice to use ?>
<?php echo "Hello World" //semicolon not required ?>
//semi colon is mandatory with multiple statements
echo "Hello World"
echo "Hello Again";
And also we can concatenate the text of two strings.
echo "Hello " . "World";