Bug #17264 Updated: Cannot call a method of the local class from preg_replace with /e option.

From: Date: Sat, 01 Jun 2002 14:18:20 +0000
Subject: Bug #17264 Updated: Cannot call a method of the local class from preg_replace with /e option.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9067@lists.php.net to get a copy of this message
ID: 17264 Updated by: mfischer@php.net Reported By: sal@stodge.org -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Linux PHP Version: 4.2.1 New Comment: You need to escape the '$', e.g.: $whatever = preg_replace( $pattern,"\$this->whatever('\\1')", $value ); Previous Comments: ------------------------------------------------------------------------ [2002-05-15 22:15:11] sal@stodge.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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17264&edit=1

« previous php.bugs (#9067) next »