Heim  >  Artikel  >  php教程  >  PHP框架的Controller

PHP框架的Controller

WBOY
WBOYOriginal
2016-06-13 10:48:022028Durchsuche

最近有在玩SAE网络营销培训(新浪的云计算平台),所以又玩回PHP。打算写个微博的应用的,于是 在写的过程里发现简单的controller机制很容易把代码搞得很混乱。于是就想着改进下控制的方式。以前一直以为controller只需要简单地把 url映射到函数或者其他什么,然后后续的工作就完全不用理了。现在想到另外一种控制:

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)


摘自 网络营销
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP判断时区判断浏览器语言Nächster Artikel:php 分页1