Re: [PHP-DEV] RE: PHP 4.0 Bug #8472 Updated: calling a function in a regular ex pression From: Cynic (cynic <email protected>)
Date: 01/08/01

check preg_replace() and the 'e' modifier.
http://docs.wad.cz/php/function.preg-replace.html
http://docs.wad.cz/php/pcre.pattern.modifiers.html

At 13:05 8.1. 2001, Simon Southwood wrote the following:
--------------------------------------------------------------
>fine, but then how is it possible to call a function withing 'ereg_replace'
>which refers to \\1 ???
>is this possible, because if it isn't, it should be.
>
>-----Original Message-----
>From: Bug Database [mailto:php-dev <email protected>]
>Sent: Monday, January 08, 2001 1:59 PM
>To: simon.southwood <email protected>
>Subject: PHP 4.0 Bug #8472 Updated: calling a function in a regular
>expression
>
>
>ID: 8472
>Updated by: cynic
>Reported By: simon.southwood <email protected>
>Old-Status: Open
>Status: Closed
>Bug Type: *Regular Expressions
>Assigned To:
>Comments:
>
>This is a user error:
>
># 34 + 5 = 39
>print(image("34"));
>
>$pat="%image([0-9])%";
>
># "fdg" . ( "\\1" + 5 ) ... i. e. "fdg5"
>$rep="fdg".image("\\1");
>
>why is \\1 not replaced with the imageID?
>
>
># ereg_replace( "%image([0-9])%" , "fdg5" , $html )
>$html=ereg_replace($pat, $rep, $html);
>
>
>Previous Comments:
>---------------------------------------------------------------------------
>
>[2001-01-08 01:53:37] simon.southwood <email protected>
>haven't tried 4.0.4, so i don't know.
> - will try to convince the admin here to upgrade ...
>
>---------------------------------------------------------------------------
>
>[2001-01-05 23:21:01] sniper <email protected>
>Have you tried PHP 4.0.4 ? Does this happen with it?
>
>--Jani
>
>---------------------------------------------------------------------------
>
>[2000-12-29 05:18:54] simon.southwood <email protected>
>oops
>$html=$html="<%image1%>some junk in here<%image2%>even more junk in
>here<%image3%>and some more for good measure<%image4%>";
>
>---------------------------------------------------------------------------
>
>[2000-12-29 04:53:38] simon.southwood <email protected>
>function image($arrayRef)
>{
>$arrayRef += 5;
>return $arrayRef;
>}
>$html="<%image1%>some junk in here<%image2%>even more junk in
>here<%image3%>and some more for good measure<%image4%>
>print(image("34"));
>$pat="%image([0-9])%";
>$rep="fdg".image("\1");
>$html=ereg_replace($pat, $rep, $html);
>
>/*
>the function works fine if "$arrayRef += 5;" is commented out (it returns
>exactly whatever "\1" is.
>it also works fine when called with either a string or an integer as
>argument, called outside the regexp function.
>
>however, inside the regexp it always returns 5.
>
>i dunno if this is a bug, if not then i do apologise, and i'll find another
>way of doing this.
>*/
>
>---------------------------------------------------------------------------
>
>
>Full Bug description available at: http://bugs.php.net/?id=8472
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>For additional commands, e-mail: php-dev-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>
------end of quote------

____________________________________________________________
Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

cynic <email protected>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>