ECHO

  • Echo is a language Construct
  • It is not a function and so it does not return any value
  • The Main advantage is,echo is ‘Faster’ than Print
  • It can take Multiple Arguments
  • Both echo and print will produce the same result
  • My personal advice is use Echo when printing ordinary statements in php

Example for echo

<?php
echo "The Author of ScriptSnippets is Sathesh";
?>

Speed Comparison between echo and print shows that echo runs at 45% of 1000 ms whereas print takes 55% of 1000ms

 

PRINT

  • Print is a function not a language construct
  • It is  a function and it returns a value either 1 or 0
  • The Main disadvantage is,Print is ‘Slower’ than Print
  • It cannot take Multiple Arguments
  • Both echo and print will produce the same result
  • My personal advice is use print when embedding html statements inside php
  • Let me Show an example to print  name inside an php embedding html tables

Example for Print

<?php
print('<table style=\"border-width:thin; border style=solid;cellpadding=1; border width=10px;")');
print("<tr>");
print("<td>");echo "The Author of ScriptSnippets is:"; print("</td>");
print("<td>");echo Sathesh;print("</td>");
print("</tr>");
print('</table>');
?>
Thank u for reading this  Article hope it was useful !
-Regards
ScriptSnippets

About Sathesh Bm

Sathesh Bm has written 26 post in this website.

Engineer, Web Lover, Thinker, Blogger

Related Posts Plugin for WordPress, Blogger...