Home>Article>Backend Development> What is the usage of php echo

What is the usage of php echo

藏色散人
藏色散人 Original
2021-11-02 10:56:55 4357browse

In PHP, echo is used to output one or more strings. Its usage syntax is "echo(strings)". The parameter strings represents one or more strings to be sent to the output.

What is the usage of php echo

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

php What is the usage of echo?

echo() function outputs one or more strings.

Note: The echo() function is not actually a function, so you don't have to use parentheses with it. However, if you wish to pass more than one argument to echo(), using parentheses will generate a parsing error.

Tip: The echo() function is slightly faster than print().

Tip: The echo() function also has abbreviated syntax. Prior to PHP 5.4.0, this syntax only worked if the short_open_tag configuration setting was enabled.

Syntax

echo(strings)

Parameters

strings Required. One or more strings to send to the output.

Example:

Example 1

Write the value of the string variable ($str) to the output:

Example 2

Write the value of the string variable ($str) to the output, including the HTML tag:

What a nice day!"; ?>

Example 3

Connect two string variables:

Example 4

Write array value to output:

"35"); echo "Peter is " . $age['Peter'] . " years old."; ?>

Example 5

Write text to output:

Example 6

How to use multiple parameters:

Example 7

The difference between single quotes and double quotes. Single quotes will output the variable name, not the value:

"; echo 'Roses are $color'; ?>

Example 8

Simplified syntax (only applicable when the short_open_tag configuration setting is enabled):

 

Roses are

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the usage of php echo. 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