echo() function in PHP

PHPProgrammingServer Side Programming

The echo() function outputs one or more strings.

Note − echo() function is faster than print().

Syntax

echo(str)

Parameters

  • str − string to be sent to the output

Return

The echo() function returns nothing.

Example

The following is an example: −

 Live Demo

<?php
   echo "Welcome!";
?>

Output

Welcome!

Example

Let us see another example −

 Live Demo

<?php
   $str1 = "Welcome!";
   $str2 = "This is our website!";
   echo $str1 . " " . $str2;
?>

Output

Welcome! This is our website!

Example

Let us see another example −

 Live Demo

<?php
   echo "This demo
   text is on
   multiple
   lines.";
?>

Output

This demo text is on multiple lines.
raja
Published on 16-Oct-2018 14:11:35
Advertisements