Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Beginner PHP Tutorial - 9 - echo
Description
In PHP there are two basic ways to get output: echo and print.
In this tutorial we use echo (and print) in almost every example. So, this chapter contains a little more info about those two output statements.
PHP echo and print Statements
echo and print are more or less the same. They are both used to output data to the screen.
The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
The PHP echo Statement
The echo statement can be used with or without parentheses: echo or echo().
Display Text
The following example shows how to output text with the echo command (notice that the text can contain HTML markup):
Example
PHP is Fun!";
echo "Hello world!
";
echo "I'm about to learn PHP!
";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
Run example »
Display Variables
The following example shows how to output text and variables with the echo statement:
Example
$txt1";
echo "Study PHP at $txt2
";
echo $x + $y;
?>
Run example »
The PHP print Statement
The print statement can be used with or without parentheses: print or print().
Display Text
The following example shows how to output text with the print command (notice that the text can contain HTML markup):
Example
PHP is Fun!";
print "Hello world!
";
print "I'm about to learn PHP!";
?>
Run example »
Display Variables
The following example shows how to output text and variables with the print statement:
Example
$txt1";
print "Study PHP at $txt2
";
print $x + $y;
?>
In this tutorial we use echo (and print) in almost every example. So, this chapter contains a little more info about those two output statements.
PHP echo and print Statements
echo and print are more or less the same. They are both used to output data to the screen.
The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
The PHP echo Statement
The echo statement can be used with or without parentheses: echo or echo().
Display Text
The following example shows how to output text with the echo command (notice that the text can contain HTML markup):
Example
PHP is Fun!";
echo "Hello world!
";
echo "I'm about to learn PHP!
";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
Run example »
Display Variables
The following example shows how to output text and variables with the echo statement:
Example
$txt1";
echo "Study PHP at $txt2
";
echo $x + $y;
?>
Run example »
The PHP print Statement
The print statement can be used with or without parentheses: print or print().
Display Text
The following example shows how to output text with the print command (notice that the text can contain HTML markup):
Example
PHP is Fun!";
print "Hello world!
";
print "I'm about to learn PHP!";
?>
Run example »
Display Variables
The following example shows how to output text and variables with the print statement:
Example
$txt1";
print "Study PHP at $txt2
";
print $x + $y;
?>
More from User
05:24
Beginner PHP Tutorial - 11 - Output HTML Using echo_print
Videos
02:18
Beginner PHP Tutorial - 10 - print
Videos
04:09
Beginner PHP Tutorial - 9 - echo
Videos
04:52
Beginner PHP Tutorial - 8 - Indentation
Videos
06:06
Beginner PHP Tutorial - 7 - The php.ini File
Videos
05:00
Beginner PHP Tutorial - 6 - The phpinfo Function
Videos
Related Videos
00:29
Développer un site web en PHP, MySQL et Javascript PDF: jQuery, CSS3 et HTML5.
Shalyutinav
00:40
php tutorials in Urdu - Hindi - 9 - use html and javascript in php
InfoVideo
02:40
PHP Tutorial Urdu - 9 - Output HTML Using echo or print Free Urdu Tutorials Video training by Pakistan Education taleem.tv
Taleem Online
05:24
Beginner PHP Tutorial - 11 - Output HTML Using echo-print
ata ul Nasar Mansoor
00:08
READ ONLINE Learning PHP MySQL JavaScript With jQuery CSS HTML5 Learning Php Mysql Javascript
Emildeluxe 1o
00:05
Learning PHP MySQL & JavaScript: With jQuery CSS & HTML5 (Learning Php Mysql Javascript Css
Majhoul 0000000