Skip to content

Commit

Permalink
Passing null to parameter #1 ($string) is deprecated in htmlspecialch…
Browse files Browse the repository at this point in the history
…ars() function.

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated.
  • Loading branch information
jeijei4 committed Aug 18, 2024
1 parent ef18216 commit 1c95811
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
```
Expand Down

0 comments on commit 1c95811

Please sign in to comment.