PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Easy fix for the PHP error “PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated”

This was the existing code that was in a WordPress plugin:

$D8 = preg_replace("\57\x5c\163\x2b\x2f\123", "\40", $D8);

This is the fixed code, which no longer throws the depreciated error:

$D8 = preg_replace("\57\x5c\163\x2b\x2f\123", "\40", (string) $D8);

If this helped you, let me know!

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.