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.
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 blocks, no need add the semicolon at end of each statement. If it’s the same 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";