Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
The PHP echo Statement
SUBMITTED BY:
lakben
DATE:
Aug. 14, 2017, 9:57 p.m.
FORMAT:
PHP
SIZE:
669 Bytes
Raw
Download
Tweet
HITS:
370
Go to comments
Report
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
echo
"<h2>PHP is Fun!</h2>"
;
echo
"Hello world!<br>"
;
echo
"I'm about to learn PHP!<br>"
;
echo
"This "
,
"string "
,
"was "
,
"made "
,
"with multiple parameters."
;
?>
Display Variables
The following example shows how to output text and variables with the echo statement:
Example:
<?php
$txt1
=
"Learn PHP"
;
$txt2
=
"bitbin.it"
;
$x
=
5
;
$y
=
4
;
echo
"<h2>
$txt1
</h2>"
;
echo
"Study PHP at
$txt2
<br>"
;
echo
$x
+
$y
;
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus