note 9638 added to ereg_replace
| From: | cparry at seas dot gwu dot edu | Date: | Thu, 16 Nov 2000 08:06:56 +0000 |
| Subject: | note 9638 added to ereg_replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7767@lists.php.net to get a copy of this message | ||
I'm using PHP 4.0.3 and I've found it impossible to use ereg_replace to escape the NUL
character in a string. It looks like the strings are cast as C-style strings internally, so a NUL
byte becomes the end-of-string marker.
echo ereg_replace("a", "A", "ab\x00cd");
result: Ab
If you're using ereg_replace with binary data, you have to handle NUL bytes yourself somehow:
echo stripslashes(ereg_replace(addslashes("a"), addslashes("A"),
addslashes("ab\x00cd")));
result: Abcd
http://www.php.net/manual/function.ereg-replace.php