This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
/
example.php
92 lines (63 loc) · 1.68 KB
/
example.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
require_once 'vendor/autoload.php';
use function Dgame\Constant\get;
use function Dgame\Constant\let;
print '<pre>';
let('global')->be('foo');
print get('global') . PHP_EOL;
function moep()
{
let('local')->be('bar');
print get('local') . PHP_EOL;
print get('global') . PHP_EOL;
}
moep();
function foo()
{
let('created')->be(time());
print __METHOD__ . ' -- created: ' . get('created') . PHP_EOL;
// let('created')->be(time());
}
foo();
foo();
let('created')->be(time());
print 'Global -- created: ' . get('created') . PHP_EOL;
function bar()
{
let('result')->be(5 * 5);
print __METHOD__ . ' -- result ' . get('result') . PHP_EOL;
}
bar();
//print 'Global -- created: ' . get('result') . PHP_EOL;
function quatz()
{
let('result')->be(6 * 6);
print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;
foo();
bar();
print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;
}
quatz();
let('foo')->be('bar');
print 'Global -- foo: ' . get('foo') . PHP_EOL;
function test()
{
let('zip_filename')->be('foo.zip');
print __METHOD__ . ' -- zip_filename: ' . get('zip_filename') . PHP_EOL;
for ($i = 0; $i < 1; $i++) {
let('img_filename')->be('bar.png');
print __METHOD__ . ' -- img_filename: ' . get('img_filename') . PHP_EOL;
}
print __METHOD__ . ' -- img_filename: ' . get('img_filename') . PHP_EOL;
print __METHOD__ . ' -- zip_filename: ' . get('zip_filename') . PHP_EOL;
}
test();
let('fac')->be(function(int $in) {
$out = 1;
// Only if $in is >= 2
for ($i = 2; $i <= $in; $i++) {
$out *= $i;
}
return $out;
});
//print 'Global -- fac: ' . get('fac')(6) . PHP_EOL;