четверг, 10 декабря 2009 г.

php - echo


For output a text, variables, html tags and etc. is used function PHP echo

PHP echo function will output the text inside it.


Example 1: output variable
<?php
$country = "Canada";
echo $country;
?>
Result:
Canada




Example 2: output text
<?php
echo "Country";
?>
Result:
Country



Example 3: output text with variable
<?php
$my_name = "Valeri";
$my_country = "Georgia";
echo "My name is" . $my_name . " and I am from " . $my_country;
?>
Result:
My name is Valeri and I am from Georgia



Example 4: output text with variables and with html tags
<?php
$my_name = "Valeri";
$my_country = "Georgia";

echo "My name is&nbsp;<b>" . $my_name . "</b><br>&nbsp;&nbsp;&nbsp;and <br>I am from&nbsp;<b>" . $my_country . "</b>";
?>
Result:
My name is Valeri
   and
I am from Georgia

Комментариев нет:

Отправить комментарий