PHP echo/print

Sujitha

 PHP echo /print

          Both 'echo' and 'print' are used in php to output  text or variable to the screen. The main different between them is that 'echo' is a language construct and doesn't return a value, while ' print' is a function and return 1, allowing it to be used in expression. Generally 'echo' is commonly used for outputing content.

   For example:

$variable=' HI! EVERYONE';
echo $variable;

         (Or)

$variable='HI!EVERYONE';
Print($variable);

PHP echo statement:

      In PHP, the echo statement is used to output the text or variable to the srceen. Its often used to display content in HTML document.

echo "HI! EVERYONE";

        Additional you can use 'echo' to output HTML elements.

echo"<h1>This is a heading</h1>";

PHP print statement:

        In PHP, the 'print ' statement is used to output the text or variable to the srceen, similar to the ' echo' statement. Print is a function and return the value ( always 1),which allows it to beused within expression.

Print" HI! EVERYONE";

          Just like with 'echo',you can use also ' print' to output HTML element.
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send