preg & callback: Why slashes?
| From: | venome at gmx dot net | Date: | Wed, 19 Jun 2002 13:17:29 +0000 |
| Subject: | preg & callback: Why slashes? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-103031@lists.php.net to get a copy of this message | ||
Is there any logical reason why all double quotes within matches are slashed
when using preg_replace with the e-modifier / callback function?
Please look at this code snippet:
-------------------------
<?php
function test($str) {
return $str;
}
$match = preg_replace('/.*/e', "test('\\0')", 'bla?
"blah!"');
// will print: bla? \"blah!\"
// --> the string passed to test() is slashed - why?
print $match;
?>
-------------------------
Now what's the use of those slashes? It simply corrupts the string if I
don't remove the slashes in the test() function.
Thank you
Sam
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net