The error message “Passing null to parameter #1 ($string) of type string is deprecated” is caused by passing a null value to the html_entity_decode() function where a string value is expected.
To fix this error, you need to make sure that the value you pass to the html_entity_decode() function is not null. You can do this by checking the value before passing it to the function, like so:
if ($string !== null) { $decoded_string = html_entity_decode($string); // Use $decoded_string as needed } else { // Handle the case where $string is null }
Alternatively, you can use the null coalescing operator (??) to provide a default value if $string is null:
$decoded_string = html_entity_decode($string ?? '');
This will set $decoded_string to an empty string if $string is null.
In general, it’s a good practice to always check for null values before passing them to functions or using them in your code, to avoid similar errors.
Another Example:
Change
html_entity_decode($string, ENT_QUOTES, 'UTF-8');
to
html_entity_decode($string ?? '', ENT_QUOTES, 'UTF-8');