Hello all welcome to findnerd, today we are going to discuss How to print HTML page with tags using PHP ?
The htmlspecialchars() Function is very useful print HTML page with tags using PHP
Firstly let know what does htmlspecialchars() Function ?
The htmlspecialchars() function is used to converting some predefined characters to HTML entities.
syntex of htmlspecialchars()
htmlspecialchars();
You can take reference of bellow example:
<!DOCTYPE html>
<html>
<body>
<!-- here write a text which you want print in php tag -->
<h3>This is a new text.</h3>
<?php
//here $str is a varibale of text
$str = "Hello Word!";
//here call htmlspecialchars() to print text
echo htmlspecialchars("<h1>This is a new text</h1>")."<br>";
//here call htmlspecialchars() to print $str variable
echo htmlspecialchars($str);
?>
</body>
</html>
Output will come following:
This is a new text
Hello Word!
0 Comment(s)