note 74536 added to function.create-function

From: Date: Mon, 16 Apr 2007 13:30:26 +0000
Subject: note 74536 added to function.create-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-125440@lists.php.net to get a copy of this message
A quick addendum to my previous note: While my method worked to introduce the desired object into the lambda function as $this, you can't actually access object methods via the $this keyword; what appears to be happening is PHP 5.x allows $this as a function parameter, passes the object into the function scope as a *variable called $this*, but when you attempt to access the variable via $this, the interpreter defaults to thinking you're using the reserved keyword $this and not a variable named $this. The workaround I had to implement was that when the anonymous function is created, I str_replace $this in the lambda function's code definition with some awkwardly-named variable like $abcdefghijklmnopqrstuvwxyz. Everything works fine after that. -Kevin ---- Server IP: 69.147.83.197 Probable Submitter: 75.9.130.114 ---- Manual Page -- http://www.php.net/manual/en/function.create-function.php Edit -- https://master.php.net/note/edit/74536 Del: integrated -- https://master.php.net/note/delete/74536/integrated Del: useless -- https://master.php.net/note/delete/74536/useless Del: bad code -- https://master.php.net/note/delete/74536/bad+code Del: spam -- https://master.php.net/note/delete/74536/spam Del: non-english -- https://master.php.net/note/delete/74536/non-english Del: in docs -- https://master.php.net/note/delete/74536/in+docs Del: other reasons-- https://master.php.net/note/delete/74536 Reject -- https://master.php.net/note/reject/74536 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125440) next »