I just found that something like
echo $value , " contiue";
will work,but this not :
return $value , " contiue";
While "." works in both occasions.
I just found that something like
echo $value , " contiue";
will work,but this not :
return $value , " contiue";
While "." works in both occasions.
the . is the concatenation operator in PHP, for putting two strings together. The comma can be used for multiple inputs to echo.
echo is actually a function (not really but let's say it is for argument) that takes any number of parameters and will concatenate them together. While return is not a function, but rather a keyword, that tells the function to return the value, and it is trying to interpret "," as some kind of operator. You should be using "." as the concatenation operator in the case when you are using the return statement.
dot is for concatenation of variable or string this is why it works when you echo while concatening two string and it works when you return a concatenation of string in a method. But the comma won't concatenate and this is why the return statement won't work.
The echo is a function that can take multiple parameter. This is why the comma works :
void echo ( string $arg1 [, string $... ] )
Use the DOT for concatenation
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.
echo
is a language construct (not a function) and can take multiple arguments, that’s why , works. using comma will be slightly even (but only some nanoseconds, nothing to worry about)
. is the concatenation operator (the glue) for strings