How to use the echo() function in php

王林
Release: 2023-03-04 11:08:01
Original
2841 people have browsed it

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)
Copy after login

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;
?>
Copy after login

Run result:

Hello world!
Copy after login

Example:

Continuously output two variables

<?php
$str1="Hello world!";
$str2="What a nice day!";
echo $str1 . " " . $str2;
?>
Copy after login

Output result:

Hello world! What a nice day!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template