In PHP, which is a better way to concatenate strings (with a single-quote) in terms of resources?
"Sal's mall is $emo."
or
"Sal's mall is ".$emo.'.'
or
'Sal\'s mall is '.$emo.'.'
In PHP, which is a better way to concatenate strings (with a single-quote) in terms of resources?
"Sal's mall is $emo."
or
"Sal's mall is ".$emo.'.'
or
'Sal\'s mall is '.$emo.'.'
'Sal\'s mall is '.$emo.'.'
3rd way is more efficient (slightly). You can test it by yourself doing a loop:
for ($i = 0; $i < 100000; $i++)
{ // enter code here
}
Well, when you use single quotes, PHP assumes it's just a string, but if you use double quotes, it's gonna parse it to find variables inside. So, using single quotes and concatenation is more efficient. Anyways, you have to test it for yourself and compare the results.
Trust me... if you have to ask, there's not going to be any meaningful difference in speed relative to the rest of your page load.
Never mind micro-optimization. Choose what makes your code more readable.
There is no difference.
Learn to profile your app before asking performance related questions.