PHP routing code
RouterCheck ();}/*** route detection */function routerCheck () {global $ config; $ this-> config = $ config; $ suffix = $ this-> config ['url _ HTML_SUFFIX ']; // Get the variable $ paths = (array_filter (explode ('/', trim (preg_replace ('/\. '. $ suffix. '$/', '', $ _ SERVER ['php _ SELF ']),'/'); if ($ this-> config ['url _ PATHINFO_MODEL '] = 1) {define ('/index. php/Article ','/'. $ paths [0]. '/');} elseif ($ this-> config ['url _ PATHINFO_MODEL '] = 2) {define ('/in Dex. php/Article ','/');} if (empty ($ paths [1]) {$ paths [1] = 'index ';} if (empty ($ paths [2]) {$ paths [2] = 'index';} if (empty ($ paths [3]) {$ paths [3] = 'index';} $ this-> Action ($ paths);}/*** instantiate operation */function Action ($ paths) {if ($ paths [1] ==$ this-> config ['tmpl _ ADMIN_PATH ']) {include APP_PATH. '/'. $ this-> config ['tmpl _ ADMIN_PATH ']. '/commonAction. php '; $ A = APP_PATH. '/'. $ paths [1]. "/". $ paths [2]. "Action. class. php "; $ B = $ paths [2 ]; @ $ C = $ paths [3];} else {$ A = APP_PATH. "/Action /". $ paths [1]. "Action. class. php "; $ B = $ paths [1]; $ c = $ paths [2];} if (is_file ($ A) {include $; $ action = $ B. "Action"; @ $ controller = new $ action (); if (method_exists ($ controller, $ c) {$ controller-> $ c ();} else {exit ('method not exist');} else {exit ('class not exist ');}} /*** resolved to $ _ GET global variable */function pathinfo () {$ pathinfo = (array_filter (explode ('/', $ this-> url ))); $ count = count ($ pathinfo); for ($ foo = 1; $ Foo <$ count; $ foo + = 2) {$ _ GET [$ pathinfo [$ foo] = ($ foo + 2) = $ count? Array_shift (explode ('. ', $ pathinfo [$ foo + 1]): $ pathinfo [$ foo + 1];} /*** rearrange the array * @ param unknown_type $ array */function Reorder ($ array) {$ I = 0; foreach ($ array as $ row) {$ a [$ I ++] = $ row;} return $ a;} function _ destruct (){}}
The above is the content of the PHP routing code. For more information, see PHP Chinese network (www.php1.cn )!