rafaelss (owner)

Revisions

  • 84d9b0 Fri Aug 08 19:07:31 -0700 2008
gist: 4646 Download_button fork
public
Public Clone URL: git://gist.github.com/4646.git
closure.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
class ActiveRecord {
 
    public static function find($id) {
        echo $id, PHP_EOL;
    }
}
 
class ActiveRecordCache {
 
    public static function cache($finder) {
        if($cached) {
            return $cachedResults;
        }
        return $finder();
    }
}
 
ActiveRecordCache::cache(function() {
    return ActiveRecord::find(1);
});
 
$find = function($id) {
    echo $id, PHP_EOL;
};
 
$find(1);
 
$array = array(1, 2, 3, 4, 5);
array_map(function($text) { echo $text, PHP_EOL; }, $array);
?>