Search code examples
phpsyntaxcompareconcatenation

Difference between period and comma when concatenating with echo versus return?


I just found that this will work:

echo $value , " continue";

but this does not:

return $value , " continue";

While . works instead of , in both the echo and return statements.

What is the difference between a period and a comma here?


Solution

  • return only allows one expression, but echo allows a list of expressions where each expression is separated by a comma.

    But note that since echo is not a function but a special language construct, wrapping the expression list in parenthesis is illegal.