ID: 48330 Updated by: j...@php.net Reported By: seateng at sohu dot com -Status: Open +Status: Bogus Bug Type: PCRE related Operating System: Redhat AS5 PHP Version: 5.2.9 New Comment:
RTFM: When using the e modifier, this function escapes some characters (namely ', ", \ and NULL) in the strings that replace the backreferences. This is done to ensure that no syntax errors arise from backreference usage with either single or double quotes (e.g. 'strlen(\'$1\')+strlen("$2")'). Make sure you are aware of PHP's string syntax to know exactly how the interpreted string will look like. Previous Comments: ------------------------------------------------------------------------ [2009-05-19 13:51:59] seateng at sohu dot com Description: ------------ preg_replace() Pattern Modifiers 'e' Bug Reproduce code: --------------- <?php $html_body = '<a href="#">asdf</a>'; echo preg_replace("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); ?> Expected result: ---------------- <A href="#">asdf</A> Actual result: -------------- <A href=\"#\">asdf</A> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48330&edit=1