Connecting Tech Pros Worldwide Forums | Help | Site Map

can we define a php function within a php function..??

Newbie
 
Join Date: Oct 2008
Posts: 26
#1: 3 Weeks Ago
if it is possible then is it a good practice to include a function inside another function..?? how can we assure about its maintenability and its performance.

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,953
#2: 3 Weeks Ago

re: can we define a php function within a php function..??


Please see anonymous functions / closures and, if you're on something older than PHP5.3, see create_function().
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,670
#3: 3 Weeks Ago

re: can we define a php function within a php function..??


not that I know of. And I wouldn’t consider it a good practice either (in contrast to javascript, where such an inner function serves a certain purpose).

EDIT: admittedly, I didn’t think of anonymous functions…
Reply