There are two basic ways to get the output in PHP:
- echo [ echo or echo() ]
- print [ print or print() ]
Note:
1- The echo
statement can be used with or without parentheses: echo
or echo()
.
2-The print statement can be used with or without parentheses: print or print().
Difference between echo and print
S.No. | echo | |
1 | does not return any value | returns an integer value, which is 1. |
2 | echo is faster than print statement. | print is slower than echo statement. |
3 | We can pass multiple strings separated by comma (,) in echo. | Using print, we cannot pass multiple arguments. |
4 | <?php $fname = “Gunjan”; $lname = “Garg”; echo “My name is: “.$fname,$lname; ?> | <?php $fname = “Gunjan”; $lname = “Garg”; print “My name is: “.$fname,$lname; ?> |