Difference Between Echo And Print in Tabular Form
SNo. | Basic Term | Echo | |
1. | Definition | Echo 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. | Syntax | void echo ( string $arg1 [, string $… ] ) | int print ( string $arg ) |
3. | Programming Language | Php | Php |
4. | Working Used | Display Output | Display Output |
5. | Display | echo ”abhi”; | print “”; |
6. | Variable | echo $val; | print $val; |
7. | Return Value | No | It Return Value of 1 |
8. | Parameters Argument | multiple | one argument |
9. | Concatenation | echo $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. | Speed | Faster than print 5.530563283 ms | Few Micro-Sec Slower 5.55189476 ms |
11. | Parentheses | Support with or without parentheses | Support 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 Quotes | echo “$name”; Result : Abhi It Read as Variable | print “$name”; Result : Abhi It Read as Variable |
14. | Behavior with IF | if(echo($name)){ //Parse error: syntax error } | if (print($name)) { // It Works} |
15. | Example | <?php $name="Abhi"; echo $name; //or echo ($name); ?> | <?php $name="Abhi"; print $name; //or print ($name); ?> |
(Visited 1,084 times, 1 visits today)
Written by: