Home  >  Article  >  Backend Development  >  What is the difference between echo and print in PHP?

What is the difference between echo and print in PHP?

Guanhui
GuanhuiOriginal
2020-07-24 11:58:461942browse

What is the difference between echo and print in PHP?

What is the difference between echo and print in PHP?

1. Echo can accept N string type parameters, while print can only receive 1 string type parameter;

2. Echo has no return value, and print does. The return value is always 1 of type int.

The two are similar:

echo and print are both language structures (official documents explain it as language construct);

echo and print are both Used to output strings;

When there is only one parameter at the same time, the parentheses (parenthesis) after echo and print are optional, that is: echo ($argument1) is equivalent to echo $argument1, print(argument) is equivalent to print argument;

echo and print will convert the parameters and try to convert them to string type before outputting.


Recommended tutorial: "PHP"

The above is the detailed content of What is the difference between echo and print 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