string htmlentities function - it converts all applicable characters to HTML entities

string htmlentities function - it converts all applicable characters to HTML entities

string-htmlentities-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 htmlentities function - it converts all applicable characters to HTML entities</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 htmlentities function - it converts all applicable characters to HTML entities">
  <meta name="keywords" content="php, example, code, array, function, htmlentities, string">
  <meta name="description" content="string htmlentities function - it converts all applicable characters to HTML entities">
  <style>
   h2, h4{background:#ddd; color:#000080;}
   h2{ padding:3px; margin:3px; font-size:21px;}
   h4{ padding:2px; margin:2px; font-size:17px;}
   p{padding:2px; margin:2px; color:#330099;}
   body{ background:#FFFFFb;}
  </style>
 </head>
 <body>
  <h2>string htmlentities function - it converts all applicable characters to HTML entities</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 ' character to equibalent html characeter by using htmlentities string function
     ------------------------------------------------------------------------------------------------------
    */
    $convertedString = htmlentities($myQuotedString);
    echo "<h4>Output of convertedString by using string htmlentities function</h4>";
    print "<p>$"."convertedString = {$convertedString}</p>";
    print "<p>string length : ".strlen($convertedString)."</p>";
    /*
     ---------------------------------------------------------------------------------------
     professionally this function is used rapidly to convert characters to html characters
     ---------------------------------------------------------------------------------------
    */
   ?>
  </pre>
 </body>
</html>


string htmlentities function - it converts all applicable characters to HTML entities - output in the browser

No comments:

Post a Comment

leave your comments here..