Default Values With htmlspecialchars()¶
The default values of htmlspecialchars() were changed in PHP 8.1. It was ENT_COMPAT and it is now replaced with ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
.
In particular, it means that '
, single quote, is now converted in HTML entities.
PHP code¶
<?php
echo htmlspecialchars("'");
?>
Before¶
After¶
PHP version change¶
This behavior changed in 8.1