PHP echo()
Function
Example
Output some text:
Definition and Usage
The echo() function outputs one or more strings.
Note: The echo() function is not actually a function, so you do not have to use parentheses with it. However, if you want to pass more than one argument to echo(), using parentheses will generate a parse error.
Tip: The echo() function is slightly faster than the print() function.
Tip: The echo() function also has a shorthand syntax. Prior to PHP 5.4.0, this syntax only works if the short_open_tag configuration setting is enabled.
Syntax
Parameter | Description |
---|---|
strings | Required. One or more strings to be sent to the output. |
Technical Details
Return Value: | No return value. |
---|---|
PHP Version: | 4+ |
--- | --- |
More Examples
Example 1
Output a string variable (
Example 2
Output a string variable (
Example 3
Concatenate two string variables:
Example 4
Output the values of an array:
Example 5
Output some text:
Example 6
How to use multiple parameters:
Example 7
The difference between single and double quotes. Single quotes will output the variable name, not the value:
Example 8
Shorthand syntax (only works if the short_open_tag configuration setting is enabled):