PHP 4.0 Bug #10626 Updated: escaping doesn't work in the replacement clause

From: Date: Fri, 04 May 2001 11:15:39 +0000
Subject: PHP 4.0 Bug #10626 Updated: escaping doesn't work in the replacement clause
Groups: php.dev 
Request: Send a blank email to php-dev+get-53797@lists.php.net to get a copy of this message
ID: 10626 User Update by: hover@mi.ru Status: Bogus Bug Type: PCRE related Description: escaping doesn't work in the replacement clause 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. Previous Comments: --------------------------------------------------------------------------- [2001-05-03 08:04:17] cynic@php.net You escaped the $1000 on the PHP level, so literal $1000 was sent to PCRE, where $10 was interpreted as a backreference, and since there aren't 10 capturing subpatterns in the pattern, you get an empty string for $10, and the rest is taken as a literal string. Send further questions to php-general@ (after you RTFM, of course). --------------------------------------------------------------------------- [2001-05-03 03:04:24] hover@mi.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 --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=10626

« previous php.dev (#53797) next »