PHP Echo  

PHP Echo

PHP Echo

PHP echo is a language construct not a function, so you don't need to use parenthesis with it. But if you want to use more than one parameters, it is required to use parenthesis.

The syntax of PHP echo is given below:

  1. void echo ( string $arg1 [, string $... ] )  

PHP echo statement can be used to print string, multi line strings, escaping characters, variable, array etc.

PHP echo: printing string

File: echo1.php

  1. <?php  
  2. echo "Hello by PHP echo";  
  3. ?>  


Hello by PHP echo

PHP echo: printing multi line string

File: echo2.php

  1. <?php  
  2. echo "Hello by PHP echo  
  3. this is multi line  
  4. text printed by   
  5. PHP echo statement  
  6. ";  
  7. ?>  


Hello by PHP echo this is multi line text printed by PHP echo statement

PHP echo: printing escaping characters

File: echo3.php

  1. <?php  
  2. echo "Hello escape \"sequence\" characters";  
  3. ?>  


Hello escape "sequence" characters

PHP echo: printing variable value

File: echo4.php

  1. <?php  
  2. $msg="Hello RedhuntStudy PHP";  
  3. echo "Message is: $msg";    
  4. ?>  


Message is: Hello RedhuntStudy PHP

Download free E-book of PHP

Learn Programming for Free

Join Programmers Community on Telegram

Talk with Experienced Programmers

Just drop a message, we will solve your queries