Echo vs Print [英] Echo vs Print

查看:79
本文介绍了Echo vs Print的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道为什么大多数人都会使用回声而不是打印。我/ b $ b $倾向于使用打印,可能是因为我开始在BASIC中编程,然后回到
78,所以它只是熟悉。


Echo可以采用多个表达式(如echo

$ string1,$ string2,$ string3),这显然比多个表达快一点

连接。但对于基本输出,似乎没有明显的

差异。 http://dynacker.dotgeek.org/printvsecho/ 上的速度测试显示

a" 5%"速度差异,但这相当于典型脚本上实际执行时间的微小差异。


所以 - 为什么选择回声? overprint,反之亦然?

解决方案

string1,


string2,

string3"),显然比多个
连接快一点。但对于基本输出,似乎没有明显的

差异。 http://dynacker.dotgeek.org/printvsecho/ 上的速度测试显示

a" 5%"速度差异,但这相当于典型脚本上实际执行时间的微小差异。


所以 - 为什么选择回声?过度打印,反之亦然?


I''m just wondering why it seems most people use "echo" instead of "print". I
tend to use "print", probably because I started programming in BASIC back in
78, so it''s just familiar.

Echo can take multiple expressions (as in "echo
$string1,$string2,$string3"), which apparently is a bit faster than multiple
concatenations. But for basic output, there doesn''t seem to be a noticeable
difference. The speed test at http://dynacker.dotgeek.org/printvsecho/ shows
a "5%" difference in speed, but this amounts to a negligible difference in
actual execution time on a typical script.

So - why does one choose "echo" over "print", or vice-versa?

解决方案

string1,


string2,


string3"), which apparently is a bit faster than multiple
concatenations. But for basic output, there doesn''t seem to be a noticeable
difference. The speed test at http://dynacker.dotgeek.org/printvsecho/ shows
a "5%" difference in speed, but this amounts to a negligible difference in
actual execution time on a typical script.

So - why does one choose "echo" over "print", or vice-versa?


这篇关于Echo vs Print的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆