#75. PHP Htmlentities & Htmlspecialchars Functions

 How to work PHP Htmlentities & Htmlspecialchars Function?
Syntax:



Run Code:
<?php

$str  = "This is 'PHP' <b>Programming.</b>";

$str = '<a href="https://sheikh1996.blogspot.com">PHP Dev Website</a>';

echo $str . "<br>";

//echo htmlentities($str, ENT_QUOTES);

// echo htmlentities($str, ENT_NOQUOTES);

// echo htmlspecialchars($str, ENT_NOQUOTES);
// echo htmlspecialchars($str, ENT_QUOTES);
//$htmlEnt = htmlspecialchars($str, ENT_NOQUOTES);
$htmlEnt = htmlspecialchars($str, ENT_NOQUOTES);

echo $htmlEnt;

//echo html_entity_decode($htmlEnt);

echo htmlspecialchars_decode($htmlEnt);
//--------------------------------------

echo "<pre>";
//print_r(get_html_translation_table(HTML_SPECIALCHARS));
print_r(get_html_translation_table(HTML_ENTITIES));

echo "</pre>";

?>

Comments

Popular posts from this blog

#30. PHP Recursive Function