string htmlspecialchars_decode function - it converts special HTML entities to equivalent characters
string-html-entity-decode-function-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>string htmlspecialchars_decode function - it converts special HTML entities to equivalent characters</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="string htmlspecialchars_decode function - it converts special HTML entities to equivalent characters">
<meta name="keywords" content="php, example, code, array, function, htmlspecialchars_decode, string">
<meta name="description" content="string htmlspecialchars_decode function - it converts special HTML entities to equivalent characters">
<style>
h2, h4{background:#ddd; color:#000086;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:19px;}
p{padding:2px; margin:2px; color:#330099;}
body{ background:#FFFFFb;}
span{ background:orange;}
</style>
</head>
<body>
<h2>string htmlspecialchars_decode function - it converts special HTML entities to equivalent characters</h2>
<pre>
<?php
/*
-------------------------------------
let us make quoted string for test
-------------------------------------
*/
$myString = "my boss mr. <span>cfsuman</span> who is a fan of <span>orange</span> color.";
echo "<h4>Output of myString in the browser</h4>";
print "<p>$"."myString = {$myString}</p>";
print "<p>string length : ".strlen($myString)."</p>";
/*
----------------------------------------------------------------------
i want to convert all special characters to equivalent html entities
by using htmlspecialchars string function
----------------------------------------------------------------------
*/
$convertedString = htmlspecialchars($myString);
echo "<h4>Output of convertedString by using string htmlspecialchars function</h4>";
print "<p>$"."convertedString = {$convertedString}</p>";
print "<p>string length : ".strlen($convertedString)."</p>";
/*
------------------------------------------------------------------------------------------------------
i want to get back original string by using htmlspecialchars_decode string function
------------------------------------------------------------------------------------------------------
*/
$originalString = htmlspecialchars_decode($convertedString);
echo "<h4>Output of originalString by using string htmlspecialchars_decode function</h4>";
print "<p>$"."originalString = {$originalString}</p>";
print "<p>string length : ".strlen($originalString)."</p>";
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..