phpprintingecho

Should I use echo or print in php scripts?


Which statement should I use in php scripts? Echo or Print? What is faster and mostly used?


Solution

  • Supposedly echo is faster, but either one would work just fine.

    Echo also offers a shortcut syntax when embedding php in HTML. i.e.

        I have <?=$foo?> foo.
    

    vs

         I have <?php echo $foo;?> foo.
    

    See https://www.php.net/manual/en/function.echo.php