Home  >  Article  >  Backend Development  >  How to use the echo() function in php

How to use the echo() function in php

王林
王林Original
2020-08-12 13:14:342828browse

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;].

How to use the echo() function in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn