Convert some predefined characters to HTML entities: in PHP
Description
The following code shows how to convert some predefined characters to HTML entities:.
Example
//from w w w . j av a 2 s .c om
<?php
$str = "XML & 'HTML'";
echo htmlspecialchars($str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo htmlspecialchars($str, ENT_QUOTES); // Converts double and single quotes
echo "<br>";
echo htmlspecialchars($str, ENT_NOQUOTES); // Does not convert any quotes
?>
The code above generates the following result.