HTML Escape and Unescape using PHP

htmlspecialchars and htmlspecialchars_decode functions

<?php

$text = '<b id="test">\'Hi\'</b>';
$escaped = htmlspecialchars($text, ENT_QUOTES);
echo $escaped.PHP_EOL;

$text = htmlspecialchars_decode($escaped, ENT_QUOTES);
echo $text;

Leave a Comment

Cancel reply

Your email address will not be published.