|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-09 23:07 UTC] phpcoder at cyberpimp dot sexventure dot com
Description:
------------
According to the documentation for preg_replace(), double-quotes, apostrophes/single-quotes, backslashes, and nulls are supposed to be returned escaped. However, only double-quotes and nulls are escaped; apostrophes/single-quotes and backslashes are returned in their original context.
Reproduce code:
---------------
<?php
header('Content-Type: text/plain; charset=US-ASCII');
$inputstring="'\"\0\\";
echo preg_replace('/([\\x00-\\xFF])/e',"strlen('$1').' chars returned ($1)'.\"\r\n\"",$inputstring);
?>
Expected result:
----------------
2 chars returned (\')
2 chars returned (\")
2 chars returned (\0)
2 chars returned (\\)
Actual result:
--------------
1 chars returned (')
2 chars returned (\")
2 chars returned (\0)
1 chars returned (\)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 12:00:02 2025 UTC |
The documentation is correct: var_dump('\''); - 1 char var_dump('\"'); - 2 chars var_dump('\0'); - 2 chars var_dump('\\'); - 1 char