note 30880 added to function.create-function

From: Date: Wed, 02 Apr 2003 08:04:50 +0000
Subject: note 30880 added to function.create-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-46105@lists.php.net to get a copy of this message
Apparently you can't refer to a class variable from an anonymous-defined function, inside a class method, using the $this keyword: class AnyClass { var $classVar = 'some regular expression pattern'; function classMethod() { $_anonymFunc = create_function( '$arg', 'if ( eregi($this->classVar, $arg) ) { return true; } else { return false; } ' ); $wontWork = $_anonymFunc('some string'); } } This would throw a warning on 'undefined variable: this'... -- http://www.php.net/manual/en/function.create-function.php http://master.php.net/manage/user-notes.php?action=edit+30880 http://master.php.net/manage/user-notes.php?action=delete+30880 http://master.php.net/manage/user-notes.php?action=reject+30880

« previous php.notes (#46105) next »