What is PHP Echo Statement

PHP echo is not a function rather it is a language construct. You can use PHP echo when you want to output one or more string. As it is not a function you don’t need to use the parenthesis with it but if you want to pass one or more arguments or parameters, you can use parenthesis with it.

PHP Echo Syntax

You can use PHP echo statement to print a string, multiline string, variables values, numbers, an array, etc.

Print String Using The PHP echo Statement

PHP echo statement can be used to print the string. You can display a string of text by using echo statement of PHP. You just need to put the string inside the echo statement. For doing this, you need the write the echo and put a single space and then after you can enter your string characters inside the double quotes. Check out below example to see how you can do so.

Output

This is the string to print.

How to Print Multiline String Using PHP Echo Statement

You can also print the multiline string using the echo statement. PHP remove the spaces automatically when printing the string. If you put one space among string words, PHP will remove those spaces. Let us see it with the example given below-

Output

This is my multiline text which you can use to display and print the words that in complete writeup create a sentence.

Display HTML Codes Using The Echo Statement

You can print content using HTML codes inside the echo statement. Suppose you want to display paragraph using the echo statement, use the HTML paragraph tag inside the echo statement as given below-

Output

This is the paragraph to display using the echo statement

Output Variables Using The Echo Statement

You can print content using HTML codes inside the echo statement. Suppose you want to display paragraph using the echo statement, use the HTML paragraph tag inside the echo statement as given below-

Output

This is the final result:70

You must also read:-

Reference:-