Free Source Code and Tutorials

Custom Search

05- PHP echo

The echo command in PHP is used to output the text in the web browser. And echo is not a function, but it is a language construct. Meaning you don’t need to use a parenthesis with it.

How to output a String?
In retrieving a string output in PHP, we use echo. We place a string variable or we can use quotes, like what we are going to do in this example.
The code below we output a “Hello everyone!”. And the text we outputting is being sent to the user in a form of web page and it is very important to use a proper HTML syntax.
In the second echo, we simply put the <h3> tag at the beginning and closed it at the end of the string. Because we are using PHP to make web pages.


  1. <?php
  2. $greetings = "Hello everyone!";
  3. echo $greetings;
  4. echo "<h3>PHP programming is fun! </h3>";
  5. ?>

Hello everyone!
PHP programming is fun!

Echoing Variables

In echoing variables using PHP is very easy because there’s no quotations are required even if the variable does not hold a string.


  1. <?php
  2. $myFirstName = "I am Christian ";
  3. $myLastName = "Ignacio am ";
  4. $age = 21;
  5. echo $myFirstName;
  6. echo $myLastName;
  7. echo $age. " Years old";
  8. ?>

I am Christian Ignacio am 21 Years old

Facebook Comments
(Visited 7 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: