boen_robot Posted February 28, 2008 Share Posted February 28, 2008 I really like PHP more than JavaScript. However, one thing about JavaScript that I like are anonymous function. That is, create a function at a moment where a callback is expected, like attachEvent('click', function(e) {/* code handler here */}) In PHP, there are functions that accept callbacks as their arguments. However, I'm wondering, could such functions possibly accept an anonymous function somehow, and how would such function actually be declared within thar argument? A case I'm particularly interested in is array_map, though the question pretty much applies to any function accepting a callback.[edit]Scratch that. I found a solution with the create_function() function. It turns out it can be used as such functions' arguments. [/edit] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.