Which is better on performance: double quoted strings with variables or single quoted strings with concatenations?

前端 未结 7 1997
暗喜
暗喜 2020-12-11 07:17

I know that using single quotes around a string in PHP is faster than using the double quotes because PHP doesn\'t need to check for variable presence in the single quoted s

7条回答
  •  青春惊慌失措
    2020-12-11 07:43

    Without testing (which is the only proper way to resolve such issues) I'd say single quoted strings with concatenation, because the strings don't have to be parsed. But it's very implementation-dependent.

    And double-quoted strings have less visual clutter and cruft. So I'd side with Jonathan in saying that the performance difference is likely not that significant that you should be worried about it; rather, go with the way that is easier to maintain and consistent within your project.

提交回复
热议问题