Handle Unicode text, emoji, encoding, normalization, code points, and safe storage.
Lessons
Escape output with htmlspecialchars and UTF-8.
PHP HTML Encoding is easiest to learn by reading the example, changing it, and observing the result.
<?php
mb_internal_encoding('UTF-8');
$text = 'café 😀';
// Use mb_* functions for correct multibyte handling
echo mb_strlen($text), "
"; // counts characters, not bytes
echo mb_substr($text, 0, 4), "
"; // "café"
echo mb_strtoupper('straße'), "
";
// Always escape output as UTF-8
echo htmlspecialchars($text, ENT_QUOTES, 'UTF-8');Practice the PHP HTML Encoding example in a small scratch file, then explain what changed and why.