Html encoder
Enter the content as html code, the system will quickly encode this html code for you, HTML Entities Escape
Enter your html code then encode
What is Html Encode tool?
The application supports online html encode, you just need to enter the html source code or the content needs to be encoded
Html encode in Php
htmlentities — Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
htmlentities ( string $string , int $flags = ENT_COMPAT , string|null $encoding = null , bool $double_encode = true ) : string
Example #2 Usage of ENT_IGNORE
$str = "\x8F!!!";
// Outputs an empty string
echo htmlentities($str, ENT_QUOTES, "UTF-8");
// Outputs "!!!"
echo htmlentities($str, ENT_QUOTES | ENT_IGNORE, "UTF-8");
Html encode in Javascript
If you don't want to use external libraries, or don't need too many options when encoding html, then you can use my code below.
Here is the html encoding with javascript short and enough to use. It can be called htmlentities in javascript
(function(window) {
window.htmlentities = {
encode: function(str) {
var buf = [];
for (var i = str.length - 1; i >= 0; i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
},
decode: function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
}
};
})(window);