【发布时间】:2013-06-10 01:50:57
【问题描述】:
我正在优化我的 PHP 代码,发现您可以通过这些方式加快回显速度 - 确切地说,您可以将 echo "The name of the user is $name" . "."; 替换为:
echo 'The name of the user is '.$name.'.';echo "The name of the user is", $name, ".";-
echo sprintf("The name of the user is %s", $name);
哪个最快?如果可能的话,我不仅想看基准测试,还想看一些技术解释。
【问题讨论】:
-
您还没有发现回显参数列表(以逗号分隔)比回显一系列用点连接的值快皮秒?
-
这真的是微优化;您是否已经优化了脚本中所有真正昂贵的元素?
-
基准测试你就知道了。
标签: php optimization