PHP 4.0 Bug #8741 Updated: preg functions interpret { as part of variable interpolation
| From: | andrei@php.net | Date: | Tue, 16 Jan 2001 20:40:09 +0000 |
| Subject: | PHP 4.0 Bug #8741 Updated: preg functions interpret { as part of variable interpolation | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-44277@lists.php.net to get a copy of this message | ||
ID: 8741
Updated by: andrei
Reported By: danbeck@dealnews.com
Old-Status: Open
Status: Closed
Bug Type: PCRE related
Assigned To:
Comments:
The {$var} construct is interpreted specially in the double-quoted strings by the Zend engine - it
will interpolate the variable so you indeed need to escape it with a backslash. This is not a PCRE
problem.
Previous Comments:
---------------------------------------------------------------------------
[2001-01-16 12:56:19] danbeck@dealnews.com
The following code does not work properly
$number = "999.00";
$precision = 2;
echo preg_replace("/.0{$precision}/", "", $number);
it echos 999.00
But if you escape the first `{' bracket, the regular expression works properly
echo preg_replace("/.0{$precision}/", "", $number);
it echos 999
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8741