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

Example

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

Output:

PHP is Fun!

Hello world!
I’m about to learn PHP!

<!DOCTYPE html>
<html>
<body>

<?php
$txt1 = “Learn PHP”;
$txt2 = “blog.eduguru.in”;
$x = 5;
$y = 4;

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

</body>
</html>

Output:

Learn PHP

Study PHP at blog.eduguru.in
9

For any query or issue, feel free to discuss on http://discuss.eduguru.in
%d bloggers like this: