当output_buffering打开时回显多个参数
Google 让互联网更快 的一次演讲中提到了在 PHP 中使用带有多个参数的 echo,而不是使用 print 或字符串连接。
echo 'The ball is ', $color;
而不是其中任何一个
echo "The ball is $color";
echo 'The ball is ' . $color;
如果输出缓冲正在发挥作用怎么办?
使用带有多个参数的 echo 和输出缓冲与使用不带输出缓冲的替代方法有什么区别?
One of Googles Let's make the internet faster talks included something about using echo with multiple arguments in PHP instead of using print or string concatenation.
echo 'The ball is ', $color;
Rather than either of these
echo "The ball is $color";
echo 'The ball is ' . $color;
What if output buffering is in play ?
What would be the difference between using echo with multiple arguments along with output buffering, vs using the alternate methods without output buffering ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请务必阅读 PHP 团队的反驳 Google 的性能提示。
具体来说,他(格温·拉斯金德)说:
Be sure to read the PHP team's rebuttal of Google's performance tips.
Specifically, he (Gwynne Raskind) says:
第一个版本应该更快一点,因为它不必解析字符串以进行变量扩展(单引号),并且不必在写入之前花时间连接两个字符串。 我不认为缓冲会影响这个
the first version should be a bit faster because it doesn't have to parse the string for variable expansion (single quotes) and it doesn't have to spend time concatenating the two strings before writing them. i don't think that buffering will affect this