View Single Post
Old 07-02-2009, 10:44 AM   #6 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Something quite cool is also the use keyword. I don't know if it's specifically for the anonymous functions, but it's great 'cause then you can pass in variables into functions that you need, but don't want to pass as a param when calling the function.

PHP Code:

$db 
= new DB();

$connect = function($host$user$pass) use($db) {

$db->connect($host$user$pass);

}

$connect('localhost''root'''); 
__________________
Tanax is offline  
Reply With Quote
The Following 2 Users Say Thank You to Tanax For This Useful Post:
codefreek (07-02-2009), Orc (07-02-2009)