English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP echo() Function Usage and Example

PHP String String Functions Manual

    The echo() function is used to output one or more strings

Syntax

void echo ( string $arg1 [, string $... ] )

Definition and Usage

It gives output in the form of one or more strings, output all parameters. It does not wrap.
Echo is not a function (it is a language structure), so you do not necessarily have to use parentheses to indicate parameters, single quotes and double quotes can be used. Echo (unlike other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass multiple parameters to echo, you cannot use parentheses.
Note: The main difference between echo and print is that echo accepts a parameter list and does not return a value.

Return Value

It does not return any value

Parameter

Serial NumberParameters and Description
1

arg1

Parameter to be output

Online Example

Try the following example to output a text string:

<?php
   //echo Example Usage
   echo 'w'3codebox";
?>
Test and see ‹/›

Output Result

w3codebox

More Examples

Output the value of the string variable ($string) containing HTML tags:

<?php
//echo Output characters containing HTML tags;
$string = "www.w"3codebox.com!";
echo $string;
echo '<br>Basic Tutorial!';
?>
Test and see ‹/›

Difference between single quotes and double quotes. Single quotes will output the variable name, not the value:

<?php
//echo Output strings using single and double quotes separately;
$color = "red";
echo "Pink are $color";
echo '<br>';
echo 'Pink are $color';
?>
Test and see ‹/›

PHP String String Functions Manual