echo() function in PHP


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.

Updated on: 26-Dec-2019

257 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements