I just discovered something.
echo $var1 , " and " , $var2;
is the same as:
echo $var1 . " and " . $var2;
What is the actual string concatenation operator in php? Should I be using . or ,?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
.operator is the concatenation operator. Your first example only works because the echo ‘function’ (technically it’s a language construct, but lets not split hairs) accepts more than one parameter, and will print each one.So your first example is calling echo with more than one parameter, and they are all being printed, vs. the second example where all the strings are being concatentated and that one big string is being printed.