最近有在玩SAE网络营销培训(新浪的云计算平台),因此又玩回PHP。打算写个微博的应用的,因而 在写的过程里发现简单的controller机制很容易把代码搞得很混乱。因而就想着改进下控制的方式。之前一直觉得controller只须要简单地把 url映射到函数或者其余什么,而后后续的工做就彻底不用理了。如今想到另一种控制:php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<?php
function
boot(
$func
) {
$context
=
array
();
while
(
$func
=
$func
(
$context
)) {
;
}
}
boot(
function
(&
$context
) {
$context
[] =
'A'
;
return
function
(&
$context
) {
$context
[] =
'B'
;
return
function
(&
$context
) {
$context
[] =
'C'
;
return
function
(&
$context
) {
var_dump(
$context
);
};
};
};
});
?>
|
以上就是个概念骨架了 (fblww-1230)网络