arimbun

PHP: echo and print

Tags: , , ,

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:

  • echo is (marginally) faster than print. Providing that the statement is in a large enough loop, one will notice a slight performance gain by using echo. It’s probably advisable in the long run, unless you’re already used to print.
  • passing mutiple string parameters is faster than concatenating multiple echo calls. See example below:
  • // "." signals concatenation and is slower
    echo "hello" . "world"
    
    // "," signals multiple arguments and is faster
    echo "hello", "world"

Tags: , , ,

Leave a Reply

© 2010 arimbun

Powered by Wordpress and Magatheme