php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17429 Using /e option within a class unable to call a local method
Submitted: 2002-05-25 19:23 UTC Modified: 2002-06-01 11:51 UTC
From: sal at stodge dot org Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.2.1 OS: Linux Redhat 7.3
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: sal at stodge dot org
New email:
PHP Version: OS:

 

 [2002-05-25 19:23 UTC] sal at stodge dot org
If you use preg_replace with the /e option from within a class you may want to call a method of the current class to perform the lookup. Intuativly a user might expect this code to work:

$whatever=preg_replace( $pattern,"$this->whatever('\\1')", $value );

That 2nd parameter is being evaluated outside the current class... In this context "$this" has no meaning outside the object,  So a method like "$this->whatever{foo)" can never be evaluated directly by this command.

The function works fine if you use it according to the instructions - that is you provide it with a globally available function it will work perfectly.

To check version & config of the my offending server:
http://sharesite.stodge.org/test.php


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-01 11:51 UTC] mfischer@php.net
You forgot to escape the '$' character:

$whatever=preg_replace( $pattern,"\$this->whatever('\\1')", $value );
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC