Official Manual Description:
Definition and Usage
Definition and usage
The Echo () function outputs one or more strings.
The Echo () function works by outputting one or more strings.
Syntax
Grammar
Echo (Strings)
Parameter parameter Description description
Strings Required. One or more strings to is sent to the output
Necessary parameters. Specify one or more strings that need to be sent to the result
Tips and Notes
Tips and attention points
Note:the Echo () function is a function of actually a, so that is not the required to use parentheses with it. However, if you want to pass more than one parameter to echo (), using parentheses would generate a parse error.
Note: the Echo () function is not a real function, so you do not have to use it necessarily. If you want to pass more than one parameter to the Echo () function, then using the parentheses "()" will produce an error.
Tip:the Echo () function is slightly faster than print ().
Tip: the Echo () function is equivalent to a simplified version of the print () function.
Tip:the Echo () function has the following shortcut syntax. See Example 5.
Tip: the Echo () function contains the following handy notation. See details: Case 5.
Example 1
Case 1
<?php $str = "Who's Kai Jim?"; Echo $str; echo "<br/>"; echo $str. " <BR/>i don ' t know! ";? >
The output of the code above would be:
The code above will output the following result:
Who ' s Kai Jim? Who ' s Kai Jim? I don ' t know!
Case 2
<?php echo "This Textspans multiplelines."; ?>
The output of the code above would be:
The code above will output the following result:
This text spans multiple lines.
Case 3
<?php echo ' This ', ' string ', ' is ', ' made ', ' with multiple parameters ';?>
The output of the code above would be:
The code above will output the following result:
This string is made with multiple parameters
Case 4
Difference of single and double quotes. Single quotes would print the variable name, not the value:
Distinguish between single quotation marks (') and double quotation marks ("). Single quotes will output the variable name, not the value of the variable:
<?php $color = "Red"; echo "Roses is $color"; echo "<br/>"; Echo ' Roses is $color ';?>
The output of the code above would be:
The code above will output the following result:
Roses is redroses is $color
Case 5
Shortcut Syntax:
Shorthand (shortcut) syntax: