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

What is the difference between echo and print in PHP?

Guanhui
Release: 2023-03-03 09:02:01
Original
2054 people have browsed it

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!

Related labels:
php
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