Simple url routing control [PHP]

Source: Internet
Author: User
Tags smarty template
No details. No define (BASE_PATH, dirname (_ FILE __). DIRECTORY_SEPARATOR); system root directory define (MODULE_PATH, BASE_PATH.modules.DIRECTORY_SEPARATOR); Module Directory $ moduleempty ($ _ GET [m])? : Strtolower ($ _ GET [m]); folder $ controlemp

No details. No define ('base _ path', dirname (_ FILE __). DIRECTORY_SEPARATOR); // system root directory define ('module _ path', BASE_PATH. 'modules '. DIRECTORY_SEPARATOR); // module Directory $ module = empty ($ _ GET ['M'])? '': Strtolower ($ _ GET ['M']); // folder $ control = emp

<无详细内容> <无>
Define ('base _ path', dirname (_ FILE __). DIRECTORY_SEPARATOR); // system root directory define ('module _ path', BASE_PATH. 'modules '. DIRECTORY_SEPARATOR); // module Directory $ module = empty ($ _ GET ['M'])? '': Strtolower ($ _ GET ['M']); // folder $ control = empty ($ _ GET ['C'])? 'Index': strtolower ($ _ GET ['C']); // file {class} $ action = empty ($ _ GET ['a'])? 'Index': strtolower ($ _ GET ['a']); // method if ($ module) {$ controlFile = MODULE_PATH. $ module. DIRECTORY_SEPARATOR. $ control. '. php'; if (! File_exists ($ controlFile) echo $ module. DIRECTORY_SEPARATOR. $ control. '. php '. 'class file does not exist'; exit (); include ($ controlFile); $ c = new $ control; if (! Method_exists ($ c, $ action) echo $ c. 'method does not exist'; exit (); $ c-> $ action ();} else {// default homepage [loading view with smarty template engine] $ smarty-> display('index.html ');}/** write a simple routing control function based on the parameter m, c, a, the module, file, and method that controls the response url. (MVC) URL. Description: MVC mode, m module [corresponding module folder], c controller [corresponding class file], method a [corresponding object method] If no module is specified, index [file | class] is accessed by default when no control is specified on the homepage of the system by default. if the file does not exist, the output file [Class] does not exist. If the action is not specified, the index [Method] is accessed by default. If the method does not exist, the output method does not exist. For example: http://www.xxx.com/web/index.php?m=admin Access the index method of the index file under the admin folder under module (the class name is the same as the file name */

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.