Home > php教程 > php手册 > PHP基础解析(2)echo与print

PHP基础解析(2)echo与print

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:57:58
Original
1720 people have browsed it

在PHP中,echo与print都可以用于输出语句,但两者还是有一定的用法区别。 1.在PHP官方手册中,echo与print实际上都不是一个函数,他们算是一种语言结构,print后面不必使用圆括号来扩起它的参数列表。echo没有返回,print有返回。 2.echo可以输出条字符串,

在PHP中,echo与print都可以用于输出语句,但两者还是有一定的用法区别。

1.在PHP官方手册中,echo与print实际上都不是一个函数,他们算是一种语言结构,print后面不必使用圆括号来扩起它的参数列表。echo没有返回值,print有返回值。

2.echo可以输出条字符串,用逗号隔开即可。print只能输出一条字符串。也就是说echo能接收不同的参数,print只能接受一个参数。

<?php echo "my name is peter" . "<br />" ."my age is 20"."<br>","my college is in Beijing","<br>";
print "my hometown is in Beijing";

?>
Copy after login
提示:(1)由于echo在运行时没有返回值,所以它的效率要略高与print,适用于一些相对简单的输出。

    (2)由于print有返回值,在输出失败时返回false,所以适用于一些比较复杂的表达式。

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template