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.
PHP Echo Example:
<?php $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
Manisha Jan 22, 2019
Nice Code.. Really helpful.