note 128843 added to function.str-replace
| From: | Anonymous at main dot php dot net | Date: | Wed, 30 Aug 2023 22:17:10 +0000 |
| Subject: | note 128843 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220805@lists.php.net to get a copy of this message | ||
str_replace always replaces NULL with empty string
Try:
var_dump(
str_replace("a", "b", [NULL]),
str_replace("a", "b", NULL)
);
What I expect:
Array(1){
[0] => NULL
}
NULL
What I get:
Array(1){
[0] => string(0)""
}
string(0) ""
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 79.37.125.60)
----
Manual Page -- https://php.net/manual/en/function.str-replace.php
Edit -- https://main.php.net/note/edit/128843
Del: integrated -- https://main.php.net/note/delete/128843/integrated
Del: useless -- https://main.php.net/note/delete/128843/useless
Del: bad code -- https://main.php.net/note/delete/128843/bad+code
Del: spam -- https://main.php.net/note/delete/128843/spam
Del: non-english -- https://main.php.net/note/delete/128843/non-english
Del: in docs -- https://main.php.net/note/delete/128843/in+docs
Del: other reasons-- https://main.php.net/note/delete/128843
Reject -- https://main.php.net/note/reject/128843
Search -- https://main.php.net/manage/user-notes.php