php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8472 calling a function in a regular expression
Submitted: 2000-12-29 04:53 UTC Modified: 2001-01-08 06:58 UTC
From: simon dot southwood at sportal dot net Assigned:
Status: Closed Package: *Regular Expressions
PHP Version: 4.0.0 OS: rh 6.02
Private report: No CVE-ID: None
 [2000-12-29 04:53 UTC] simon dot southwood at sportal dot net
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.
*/

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-29 05:18 UTC] simon dot southwood at sportal dot net
oops 
$html=$html="<%image1%>some junk in here<%image2%>even more junk in
here<%image3%>and some more for good measure<%image4%>";
 [2001-01-05 23:21 UTC] sniper@php.net
Have you tried PHP 4.0.4 ? Does this happen with it?

--Jani
 [2001-01-08 01:53 UTC] simon dot southwood at sportal dot net
haven't tried 4.0.4, so i don't know.
 - will try to convince the admin here to upgrade ... 
 [2001-01-08 06:58 UTC] cynic@php.net
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"); 

# ereg_replace( "%image([0-9])%" , "fdg5" , $html )
$html=ereg_replace($pat, $rep, $html); 

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC