note 30886 added to function.create-function
| From: | DB at rack1 dot php dot net | Date: | Wed, 02 Apr 2003 10:58:07 +0000 |
| Subject: | note 30886 added to function.create-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46111@lists.php.net to get a copy of this message | ||
What I posted above is logical because anonymous functions don't inherit the method scope.
You'll have to do this:
class AnyClass {
var $classVar = 'some regular expression pattern';
function classMethod() {
$_anonymFunc = create_function( '$arg1, $arg2', 'if ( eregi($arg2, $arg1) ) {
return true; } else { return false; } ' );
$willWork = $_anonymFunc('some string', $classVar);
}
}
--
http://www.php.net/manual/en/function.create-function.php
http://master.php.net/manage/user-notes.php?action=edit+30886
http://master.php.net/manage/user-notes.php?action=delete+30886
http://master.php.net/manage/user-notes.php?action=reject+30886