PHP Echo Tutorials


In PHP, the two basic constructs are used to get outputs which are echo and print. Actually, echo is not a kind of function, it is a language construct, hence, you can use it with or without parentheses such as echo or echo(). The echo means outputting the text to the browser. Throughout, your PHP practice you will be using the echo command more than any other command of PHP. So let’s start to output the text in a proper way.

To print a string by using the PHP echo command you can place either a string variable or you can use the quotes, like we do below, to make a string that the echo function will display.

For Example:


$myString = “Hello!”;

echo $myString;

echo “<h5>I love using PHP!</h5>”;




I love using PHP!

In the above example, we get the string “Hello” without a hitch. The text we are outputting is being sent to the user in the structure of a web page, so it is essential that we use proper HTML code.

In our second echo statement, we use echo to print a valid Header 5 HTML statement. To do this, we easily put the <h5> at the starting of the string and closed it at the end of the string. Just because you are using PHP to develop web pages does not mean you can forget about HTML code.

PHP echo is use for print the program on server. echo and print almost are same, but echo return value is zero and print return value is 1.



echo “I am using PHP”;


RESULT: I am using PHP



$mystring = “Hello Joe. I am: “;
echo “$my_string Stephen”;


Result: Hello Joe. I am: Stephen

Coding Tag

Coding Tag always happy to serve you in Information Technology (IT). Learn HTML, CSS, Javascript, PHP, Android, Digital Marketing, Latest IT News and many more.

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Manisha Recent comment authors
newest oldest most voted
Notify of

Nice Code.. Really helpfull.