为什么 "echo" 语句支持在一行中输出多个参数而 "echo" 函数不支持?

Why does the "echo" statement support outputting multiple arguments in a single line and the "echo" function does not?

在 PHP 中,您可以使用 echo 语句 一次输出多个参数,如下所示:

echo "Mangoes", " ", "are", " ", "tasty.";

当您尝试对 echo 函数 执行相同操作时,如下所示:

echo("Mangoes", " ", "are", " ", "tasty.");

你得到一个错误,为什么会这样?
这可能是因为 PHP 希望您使用字符串连接而不是多个参数?

提前致谢。

因为echo不是函数。文档清楚地说明了这一点:

echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.

当你调用echo()时,意味着你调用了echo()的函数。 echo只有一个参数echo(_string_)。因此,当您在 echo 参数的括号中包含 , 符号时,这意味着您使 echo 函数具有多个参数。所以你不能这样做 echo("Mangoes", " ", "are", " ", "tasty.");

请看这个http://www.w3schools.com/php/func_string_echo.asp