How to display HTML code as Text
Replace <
with <
and >
with >
.
Example:
<center>Hello</center>
Output:
<center>Hello</center>
Displaying HTML code as text in PHP
Use htmlspecialchars()
function in PHP.
If you want to display HTML code as text in PHP, the easiest way to do so is to use htmlspecialchars()
function.
Example:
<?php echo htmlspecialchars('<strong>Hello</strong>'); ?>
Output:
<strong>Hello</strong>