Difference Between Echo And Print in Tabular Form

SNo.Basic TermEchoPrint
1.DefinitionEcho is display strings and variable ,echo is not a really function but a language construct.print is display strings and variable ,print is not a really function but a language construct.
2.Syntaxvoid echo ( string $arg1 [, string $… ] )int print ( string $arg )
3.Programming LanguagePhpPhp
4.Working UsedDisplay OutputDisplay Output
5.Displayecho ”abhi”;print “”;
6.Variableecho $val;print $val;
7.Return ValueNoIt Return Value of 1
8.Parameters Argumentmultipleone argument
9.Concatenationecho $name,$profile, $age, ” years old”;
Or
echo ‘Name :’.$name.’Profile :’.$profile.’ Age :’.$age.’ years old’;
Print $name,$profile, $age, ” years old”;
Parse error syntax error
10.SpeedFaster than print 5.530563283 msFew Micro-Sec Slower 5.55189476 ms
11.ParenthesesSupport with or without parenthesesSupport with or without parentheses
12.Single Quotes<?php
echo ‘$name’;
?>
Result : $name
It Read as character
<?php
print ‘$name’;
?>
Result : $name
It Read as character
13.Double Quotesecho “$name”;
Result : Abhi
It Read as Variable
print “$name”;
Result : Abhi
It Read as Variable
14.Behavior with IFif(echo($name)){
//Parse error: syntax error
}
if (print($name)) {
// It Works}
15.Example
(Visited 34 times, 1 visits today)

Written by:

Leave a Reply

Your email address will not be published. Required fields are marked *