|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-05-03 03:04 UTC] hover at mi dot ru
The problem is that preg_replace() ignores escaping of $nn sequence in the replacement string.
<?
$str = preg_replace("/a/", "\$1000", "test ... a ... test");
echo $str;
?>
test ... 00 ... test
-----------
#!/usr/local/bin/perl -w
$_ = "test ... a ... test";
s/a/\$1000/;
print;
-----------
test ... $1000 ... test
This feature leads to impossibility of passing strings like '$1000' via phplib template variables.
PHP 4.0.4pl1, 4.0.5
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
Thanks for educating me and sorry for waisting your time. Though, phplib template.inc needs to be changed to work with such variables. Something like this: $tempvars = preg_replace("/\\$/", "\\\\\$", $this->varvals); But it's a phplib's, not PHP thing. Thanks.