Home >Backend Development >PHP Problem >How to use the echo() function in php
The echo() function is used to output one or more strings. This function has no return value. It should be noted that the echo() function is not actually a function, so there is no need to use parentheses around it. The specific usage is as follows: [$str = "Hello world!"; echo $str;].
Function introduction:
echo() function outputs one or more strings. It has no return value.
(Recommended tutorial: php graphic tutorial)
Note: The
echo() function is not actually a function, so you don’t have to use it brackets. If you want to pass more than one argument to echo(), using parentheses will generate a parsing error.
The echo() function is slightly faster than print().
Syntax:
echo(strings)
Parameters:
strings Required. One or more strings to send to the output.
(Video tutorial recommendation: php video tutorial)
Example:
<?php $str = "Hello world!"; echo $str; ?>
Run result:
Hello world!
Example:
Continuously output two variables
<?php $str1="Hello world!"; $str2="What a nice day!"; echo $str1 . " " . $str2; ?>
Output result:
Hello world! What a nice day!
The above is the detailed content of How to use the echo() function in php. For more information, please follow other related articles on the PHP Chinese website!