Thursday, January 22, 2009

What is the difference between echo and print statement?

  • echo() can take multiple expressions, print cannot
    take multiple expressions.

  • echo has the slight performance advantage because
    it doesn't have a return value. So, echo is a little bit faster but print
    return a integer value of 1.


  • <?php

    if(print('something'))

    // makes sense, while

    if(echo('something'))

    // doesn’t

    ?>

    No comments:

    Post a Comment