Friday, 16 November 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...