PHP function echo () definition and usage analysis. Output one or more strings when using the definition and usage PHP function echo. The description of the echo (strings) parameter is required. One or more strings to be sent to the output. Prompt to use
Definition and usage
The PHP function echo () outputs one or more strings.
Syntax
Echo (strings)
Parameter description
Strings is required. One or more strings to be sent to the output.
Tips and comments
Note: echo () is actually not a function, so you do not need to use parentheses for it. However, if you want to pass one or more parameters to echo (), a parsing error occurs when brackets are used.
Tip: The echo () function is a little faster than the print () function.
Tip: PHP function echo () can use simplified syntax. See the following example.
- <html> <body>
- php $color = "red"; ?>
- <p>Roses are
- =$color?>
- p>
- body>
- html>
1. echo output scalar
- Php
- Echo 123adb; // The output is correct.
- Echo 123abd; // correct
- Echo "123adb"; // correct
- ?>
2. PHP function echo () output variable, constant
- Php
- $A="123456";
- Echo $ a; // correct
- Echo" Br>";
- Echo "$ a"; // correct
- Echo" Br>";
- Echo $ a; // incorrect
- Echo" Br>";
- Echo abcdef; // it can be correctly displayed, but it is strongly not recommended to do so,
This is because many special characters cannot be correctly displayed.
- Echo" Br>";
- // Echo<Abd>; // For example, if the tip is included, it cannot be used,
You can go to the previous comment and try to see if it will return an error.
- Echo" Br>";
- $B=10;
- Echo $ B + 10; // Display 20
- Echo" Br>";
- Echo "$ B + 10 ";
- Echo" Br>";
- Echo "the result is:". "$ B"; // The two statements have the same effect.
- Echo" Br>";
- Echo "result: $ B"; // The two statements have the same effect.
- ?>
Echo "" is different from PHP function echo (). when double quotation marks are added, variables and specific symbols are escaped, the single quotation marks are output directly, so it is faster to use single quotation marks than to use double quotation marks. Do not use double quotation marks.
Define and use the PHP function echo () to output one or more strings. The description of the echo (strings) parameter is required. One or more strings to be sent to the output. Prompt...