解决三大常见问题:五十个小技巧提高 PHP 执行效率
后记
4、echo 比 print 快,并且使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接,比如echo $str1,$str2。
上面标注的链接可能是译文,从发布时间(由于未标注原文地址,遂原文发布时间不详)到现在,PHP 已经迭代过很多版本,有些优化技巧可能不再适用了。
我测试过 echo
适用逗号和句点的区别,PHP 7.4.1 cli 下使用句点更快一些,难道是我的方式不对?
附测试代码地址:https://gist.github.com/c6c975cac22643419fe70b1ada2070c1。
References
- https://www.9sep.org/solution-php-problem-improve-performance.
- https://gist.github.com/c6c975cac22643419fe70b1ada2070c1 "Which is faster between comma and dot when in echo statement?".