note 104412 added to functions.variable-functions

From: Date: Tue, 14 Jun 2011 12:01:17 +0000
Subject: note 104412 added to functions.variable-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-180508@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 195.153.211.3 ---- Manual Page -- http://www.php.net/manual/en/functions.variable-functions.php Edit -- https://master.php.net/note/edit/104412 Del: integrated -- https://master.php.net/note/delete/104412/integrated Del: useless -- https://master.php.net/note/delete/104412/useless Del: bad code -- https://master.php.net/note/delete/104412/bad+code Del: spam -- https://master.php.net/note/delete/104412/spam Del: non-english -- https://master.php.net/note/delete/104412/non-english Del: in docs -- https://master.php.net/note/delete/104412/in+docs Del: other reasons-- https://master.php.net/note/delete/104412 Reject -- https://master.php.net/note/reject/104412 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180508) next »