PHP print Statement

5 (100%) 3 votes

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):


print “<h2>PHP is Fun!</h2>”;
print “Hello world!<br>”;
print “I’m about to learn PHP!”;


PHP is Fun!

Hello world!
I’m about to learn PHP!

<!DOCTYPE html>

$txt1 = “Learn PHP”;
$txt2 = “”;
$x = 5;
$y = 4;

print “<h2>” . $txt1 . “</h2>”;
print “Study PHP at ” . $txt2 . “<br>”;
print $x + $y;



Learn PHP

Study PHP at

For any query or issue, feel free to discuss on
%d bloggers like this: