Thursday, 25 September 2014

echo in PHP

The PHP echo() function is utilized to print a output string.

Syntax:

echo(strings)
strings : Required. One or more strings for output.
Tip : The PHP echo() function is somewhat faster than print().

Example:

<?php 
echo "<strong>Example 1</strong> <br />";
$input_str = "What's this Sam?";
echo $input_str;
echo "<br />";
echo $input_str."<br /> I don't know!<br />";
echo "<strong>Example 2</strong> <br />";
$pl_name = "Sam";
echo "Do you want coffee $pl_name";
echo "<br />";
echo 'Do you want coffee $pl_name';
?>

Output will be:

Example 1
What's this Sam?
What's this Sam?
I don't know!
Example 2
Do you want coffee Sam
Do you want coffee $pl_name

0 comments:

Post a Comment