I want to combine two variables together:
$var1 = 'Welcome ';
$var2 = $_SESSION['UserName'];
Which of these will work faster? Code sample 1:
$var3 = $var1.$var2;
Or code sample 2:
$var3 = "$var1$var2";
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.
Code sample 1 won’t work at all..
Syntax considerations set aside, Sample 1 should be trivially faster because it doesn’t involve parsing a string (looking for variables).
But it’s very, very trivial..