note 104412 deleted from functions.variable-functions by danbrown
| From: | danbrown@php.net | Date: | Tue, 14 Jun 2011 14:59:57 +0000 |
| Subject: | note 104412 deleted from functions.variable-functions by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180518@lists.php.net to get a copy of this message | ||
Note Submitter: dbsuk2011
----
Is there anything wrong with the following code?
Should I avoid this practice?
// temp function
$postDelete = function() {
// do something after delete occurs
};
I ask because I am using Zend Studio which highlights the "function" keyword as an error
(unexpected "function").
// from code snippet
public function deleteAction() {
// function
$postDelete = function() {
// do something after delete occurs
};
// delete the obj
$this->delete(new Content_Model_DatabaseObject_ContentItem(), $postDelete);
}
The code Parses (PHP5.3) perfectly.
I wanted to use this approach to pass a temporary function into another function to the be called
from within that function.
I know theres other ways I could achieve the same, but this seems very straight forward way to pass
functionality through functions.
Any comments appreciated.