{"id":643,"date":"2025-08-13T17:15:02","date_gmt":"2025-08-13T21:15:02","guid":{"rendered":"https:\/\/www.amixa.com\/blog\/?p=643"},"modified":"2025-08-13T17:15:42","modified_gmt":"2025-08-13T21:15:42","slug":"php-deprecated-preg_replace-passing-null-to-parameter-3-subject-of-type-arraystring-is-deprecated","status":"publish","type":"post","link":"https:\/\/www.amixa.com\/blog\/2025\/08\/13\/php-deprecated-preg_replace-passing-null-to-parameter-3-subject-of-type-arraystring-is-deprecated\/","title":{"rendered":"PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated"},"content":{"rendered":"<p>Easy fix for the PHP error &#8220;PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated&#8221;<\/p>\n<p>This was the existing code that was in a WordPress plugin:<\/p>\n<pre>$D8 = preg_replace(\"\\57\\x5c\\163\\x2b\\x2f\\123\", \"\\40\", $D8);<\/pre>\n<p>This is the fixed code, which no longer throws the depreciated error:<\/p>\n<pre>$D8 = preg_replace(\"\\57\\x5c\\163\\x2b\\x2f\\123\", \"\\40\", (string) $D8);<\/pre>\n<p>If this helped you, let me know!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Easy fix for the PHP error &#8220;PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated&#8221; This was the existing code that was in a WordPress plugin: $D8 = preg_replace(&#8220;\\57\\x5c\\163\\x2b\\x2f\\123&#8221;, &#8220;\\40&#8221;, $D8); This is the fixed code, which no longer throws the depreciated error: $D8 = preg_replace(&#8220;\\57\\x5c\\163\\x2b\\x2f\\123&#8221;, &#8220;\\40&#8221;, (string) $D8); If this helped you, let me<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[146,147,41],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-php","category-wordpress","category-wordpress-tips"],"_links":{"self":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":2,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/643\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}