In PHP there are two basic ways to get output: echo and print.
In this tutorial we use echo (and print) in almost every example. So, this chapter contains a little more info about those two output statements.
Echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.
There are some differences between echo and print:
The echo statement can be used with or without parentheses: echo or echo().
The following example shows how to output text with the echo command (notice that the text can contain HTML markup):
The print statement can be used with or without parentheses: print or print().
The following example shows how to output text with the print command (notice that the text can contain HTML markup):
The following example shows how to output text and variables with the print statement: