print 无括号常量参数的疑问

WBOY
Release: 2016-06-06 20:40:13
Original
1135 people have browsed it

$a=1;$b=2;
print $a,PHP_EOL,$b,PHP_EOL;
echo $a,PHP_EOL,$b,PHP_EOL;

官方说文文档里面说两者都支持逗号分隔的参数列表.但是遇到这种常量参数的情况下print会报错,echo 不会。
这算不算一个bug?

回复内容:

$a=1;$b=2;
print $a,PHP_EOL,$b,PHP_EOL;
echo $a,PHP_EOL,$b,PHP_EOL;

官方说文文档里面说两者都支持逗号分隔的参数列表.但是遇到这种常量参数的情况下print会报错,echo 不会。
这算不算一个bug?

楼主没有仔细看文档把, print, echo 都不是一个函数, 是一个语言结构, 所以可以省略括号,
但是 print 方法只接受一个参数, 而 echo 方法接受可变参数.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!