php - Why does the "echo" statement support outputting multiple arguments in a single line and the "echo" function does not?
264
In PHP you can output multiple arguments at once with theecho
statement like this:
echo "Mangoes", " ", "are", " ", "tasty.";
When you try to do the same with theecho
function like this:
echo("Mangoes", " ", "are", " ", "tasty.");
You get a error, why is this so?
Could this be because PHP wants you to use string concatenation instead of multiple arguments?
Thank you in advance.
Answer
Solution:
Because
is not a function. The docs clearly state this:
Answer
Solution:
when you call
echo()
its mean you call the function ofecho()
. The echo just has one parameterecho(_string_)
. SO when you include the , sign in the bracket of echo parameter, so it means you make echo function has more than one parameter. So you are not allowed to do like thisecho("Mangoes", " ", "are", " ", "tasty.");
Please see this http://www.w3schools.com/php/func_string_echo.asp