ID: 10228 Updated by: andrei Reported By: [EMAIL PROTECTED] Old-Status: Assigned Status: Closed Bug Type: Regexps related PHP Version: 4.0.4 Assigned To: andrei Comments: It seems to work, at least in the latest CVS. Previous Comments: --------------------------------------------------------------------------- [2001-04-07 18:35:09] [EMAIL PROTECTED] I'm running PHP version 4.04, Windows NT 5.0 build 2195. Using the "e" modifier with preg_replace is supposed to evaluate the replacement term prior to doing the replace. The problem is that it chokes with errors when the term to be evaluated contains quotes. Try using "e" to evaluate a PHP expression like: strtoupper("this phrase has spaces") It gives an error: Warning: Unexpected character in input: '' (ASCII=92) state=1 in framework_func.php(15) : regexp code on line 1 Parse error: parse error in framework_func.php(15) : regexp code on line 1 Fatal error: Failed evaluating code: strtoupper("This phrase has spaces") in framework_func.php on line 15 However, it WILL allow you to pass a string with no quotes, as long as it doesn't have spaces! As an example, I use this bit of code to to allow any term enclosed in curlies in a string to be evaluated as PHP: preg_replace("/({)(.*?)(})/e", "$2", $string); If $string contains "{strtoupper(no_spaces)}", that term will be replaced with "NO_SPACES" upon execution of the preg_replace. So far so good. But it fails with "{strtoupper(has spaces, no quotes)}" AND with "{strtoupper("has spaces and quotes")}. Of course, the latter is the way one would expect it to work, because it's valid PHP. I have hopes that the new function preg_replace_callback will allow me to work around this, but it seems as if the e modifier should allow you to evaluate ANY legal PHP fragment. Sorry if this is already known or is not considered a bug. --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=10228&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]