php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30709 preg_replace() and /e modifier not working with classes
Submitted: 2004-11-07 05:50 UTC Modified: 2004-11-07 08:24 UTC
From: cristian dot melendez at gmail dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 5.0.1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cristian dot melendez at gmail dot com
New email:
PHP Version: OS:

 

 [2004-11-07 05:50 UTC] cristian dot melendez at gmail dot com
Description:
------------
i'm using preg_replace() with the /e modifier to force php code to be run at the replacement.

preg_replace() and /e won't work if, instead of a regular function, i use a class object.

Reproduce code:
---------------
code shown in http://www.php.net/preg_replace
<?php
preg_replace("/(<\/?)(\w+)([^>]*>)/e", 
             "'\\1' . strtoupper('\\2') . '\\3'", 
             $html_body);
?>

my code:
<?php
 $someclass = new someclass();
preg_replace("/(<\/?)(\w+)([^>]*>)/e", 
             "'\\1' . $someclass->somefunction('\\2') . '\\3'", 
             $html_body);
?>

Expected result:
----------------
preg_replace ignores $someclass->somefunction() and just returns the text.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-07 08:24 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC