i

PHP Tutorial

PHP Echo & Print

Echo is a very basic command in PHP. Echo prints the value given between the optional open and closed brackets and the quotation marks. You can write the text in open and closed quotation marks that you want to print on the web page. End the echo command with a semicolon.

>Simple print command

Echo is basically a command that allows you to write information out on the HTML document. If you check the source code, it will show the HTML printing out the text written within Echo command of Php into the body tag.

For e.g. 

Echo (“ It is a print command”);

?>

 >Writing HTML inside echo

You can also write HTML code inside the quotation marks after echo command. For e.g., if we want to print header on an HTML page, we can write the below statement in php.

echo “

First Site Header ”;

?>

If you check the output of this code, you will get the First Site header printed in H1 settings and the source code will include header tag and code inside the body tag of HTML. You can also add a paragraph or other HTML tags inside the echo command.