PHP routing code-PHP source code

Source: Internet
Author: User
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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.