string html_entity_decode function - it converts all HTML entities to their relevant 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 html_entity_decode function - it converts all HTML entities to their relevant 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 html_entity_decode function - it converts all HTML entities to their relevant characters">
<meta name="keywords" content="php, example, code, array, function, html_entity_decode, string">
<meta name="description" content="string html_entity_decode function - it converts all HTML entities to their relevant characters">
<style>
h2, h4{background:#eee; color:#000085;}
h2{ padding:3px; margin:3px; font-size:22px;}
h4{ padding:2px; margin:2px; font-size:18px;}
p{padding:2px; margin:2px; color:#330100;}
body{ background:#FFFFFa;}
span{ background:orange;}
</style>
</head>
<body>
<h2>string html_entity_decode function - it converts all HTML entities to their relevant characters</h2>
<pre>
<?php
/*
-------------------------------------
let us make quoted string for test
-------------------------------------
*/
$myQuotedString = "my boss <span>cfsuman's</span> favorite color is <b>orange</b>.";
echo "<h4>Output of myQuotedString in the browser</h4>";
print "<p>$"."myQuotedString = {$myQuotedString}</p>";
print "<p>string length : ".strlen($myQuotedString)."</p>";
/*
------------------------------------------------------------------------------------------------------
i want to convert the tag characters to equivalent html characeter by using htmlentities string function
------------------------------------------------------------------------------------------------------
*/
$convertedString = htmlentities($myQuotedString);
echo "<h4>Output of convertedString by using string html_entity_decode function</h4>";
print "<p>$"."convertedString = {$convertedString}</p>";
print "<p>string length : ".strlen($convertedString)."</p>";
/*
------------------------------------------------------------------------------------------------------
i want to get original string back by using html_entity_decode string function
------------------------------------------------------------------------------------------------------
*/
$originalString = html_entity_decode($convertedString);
echo "<h4>Output of originalString by using string html_entity_decode function</h4>";
print "<p>$"."originalString = {$originalString}</p>";
print "<p>string length : ".strlen($originalString)."</p>";
/*
----------------------------------------------------------------------------------------------------------
professionally this function is used rapidly to convert html characters to equivalent readable characters
----------------------------------------------------------------------------------------------------------
*/
?>
</pre>
</body>
</html>

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