Tags
Asked 3 years ago
10 Aug 2021
Views 259
Letitia

Letitia posted

Why echo is used in PHP ?

Why echo is used in PHP ?
Phpworker

Phpworker
answered Aug 10 '21 00:00

echo is used for the print string or variable value .

static string print by echo:



<?php 
echo "Hello world";
?>

output :

Hello world


echo with variables :



<?php 
$var="Hello world"
echo $var;
?>

output :

Hello world


how to combine variable and static string with echo :
use (.) dot to combine variable and static string or in "" (double quote) variable parsed and repalced its value as you can see in the below example


<?php 
$var="Hello"
echo $var.' World';
echo "$var World";
?>

output :

Hello world
Hello world
Post Answer