diff --git a/README.md b/README.md index 2bf515c..6ec59d5 100644 --- a/README.md +++ b/README.md @@ -183,8 +183,12 @@ The following function uses the `htmlspecialchars` function with specific flags to ensure proper encoding: ```php -function html(string $text = null): string +function html(?string $text = null): string { + if (null === $text) { + return ''; + } + return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } ```