Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

&#039;

PHP version change

This behavior changed in 8.1.

See Also

Extension

© 2023-2026, Damien Seguy - Exakat