PHP Echo / Print

If you want to print message by php you can use echo and print

Example

<?php

 echo "Hello how are you";  // You can write string single or double quote

echo "<br>";  // You can use HTML Tag and This is HTML br Tag

echo (" Hello I am fine ");  // You can also write parethesis bracket

?>

Result

Hello how are you

Hello I am fine


Print variable

Example

<?php

 print "Use php print  "; // You can write string single or double quote

print "<br>"; // You can write HTM Tag

print (" Php is server side language");  //You can write string in parethesis bracket

?>

Result

Use php  print

Php is server side language

Difference between echo and print

Echo : You can display more than one string in same time ;

Print : You can display only one string in same time 

Tips : If you try to print more than one string by print it give error

Tips  : echo is faster than print  . Maximum  developer use echo

 Example

   Echo

<?php

/* . dott is use in php for concatenate the string */

echo "Hello How "." Ya I am fine";  /*  . concatenate string  and convert into single string */

echo "<br>";   /* <br> tag use for line break */

echo "Hii I am joe", " Hey I am chandra";

?>

Result

Hello How Ya I am fine

Hii I am joe , Hey I am chandra


Example

  Print

<?php

/* . concatination sign use to join string or variable to an other string or variable */

print "Hey Bro kaise ho"."Ya bro I am fine";

print "What are you doing" , " Hey I am reding";   /* It give syntax error */

// You can not use  , ( comma ) in print statement

?>

Result

Hey Bro kaise ho Ya bro I am fine

echo  '<br>'

Php use <br> tag for line break

Example