PHP - “Sal's mall is $emo"vs "Sal's mall is ".$emo - 带引号的字符串连接效率 [英] PHP - "Sal's mall is $emo" vs "Sal's mall is ".$emo - string with quotes concatenation efficiency
本文介绍了PHP - “Sal's mall is $emo"vs "Sal's mall is ".$emo - 带引号的字符串连接效率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 PHP 中,根据资源连接字符串(使用单引号)的更好方法是什么?
In PHP, which is a better way to concatenate strings (with a single-quote) in terms of resources?
"Sal's mall is $emo."
或者:
"Sal's mall is ".$emo.'.'
或者:
'Sal\'s mall is '.$emo.'.'
推荐答案
'Sal\'s mall is '.$emo.'.'
第三种方式效率更高(略).你可以自己做一个循环来测试它:
The third way is more efficient (slightly). You can test it by yourself doing a loop:
for ($i = 0; $i < 100000; $i++) {
// enter code here
}
这篇关于PHP - “Sal's mall is $emo"vs "Sal's mall is ".$emo - 带引号的字符串连接效率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文