Both commands are used to display some output, so what’s the difference? I chanced upon an interesting article that covers the differences between the two. I’ll put up the summary here:
echois (marginally) faster thanprint. Providing that the statement is in a large enough loop, one will notice a slight performance gain by usingecho. It’s probably advisable in the long run, unless you’re already used toprint.- passing mutiple string parameters is faster than concatenating multiple
echocalls. See example below:
// "." signals concatenation and is slower echo "hello" . "world" // "," signals multiple arguments and is faster echo "hello", "world"
Recent Comments