Friday, November 16, 2018

php - 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 in both.




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


Answer



return does only allow one single 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.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...