PHP 在双引号上工作是否更加努力(即更多处理)?

发布于 2024-10-09 21:04:28 字数 80 浏览 0 评论 0原文

PHP 是否因为搜索变量而对带引号的字符串添加了更多处理?

如果是这样,最好使用单引号并将它们分解为变量。或者说,什么方法比较好呢?

Is it true that PHP adds more processing for quoted strings because it searches for variables?

If so, is it better to use single quotes and break them up for variables. Or, what method is better?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-10-16 21:04:28

是的,由于双引号允许 PHP 执行变量插值,因此将会有(非常非常小,甚至我敢说几乎理论)性能损失(仅限标记器)查找其值要替换到字符串中的变量。

但是,在单引号或双引号之间进行选择时,性能不应成为决定因素。可读性会是一个稍微好一些的问题。也就是说,一个人大脑的表现比口译员的表现受到的影响更大。

Yes, since double quotes allow PHP to perform variable interpolation, there will be a (very very small, even I dare say almost theoretical) performance hit (tokenizer only) as it finds variables whose values to replace into the strings.

However, performance should not be the deciding factor when choosing between single quotes or double quotes. Readability would be a slightly better concern. That is, performance of one's brain would be affected more than performance of the interpreter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文