THINKPADE400578MDC thinkphp using modules and operation analysis

Source: Internet
Author: User
Any web behavior can be considered to be an operation of a module, and the system will parse the modules and actions to be executed according to the current URL. This analysis is implemented by the URL scheduler, which is the official built-in dispatcher class to complete the dispatch. In the dispatcher scheduler, it is based on the
Http://servername/appName/moduleName/actionName/params
To get the currently required items (AppName), modules (ModuleName), and Operations (ActionName), in some cases appName can be unwanted (usually the homepage of the site, because the project name can be specified in the portal file, in which case AppName will be replaced by the import file). In the case of complications, groupings (groupName) may also occur.
Each module is an action file, similar to what we normally call the controller, the system will automatically find the Project Class Library action directory under the relevant class, if not found, will be positioned to empty module, otherwise throws an exception.
The actionname operation is to first determine whether there is a public method of the action class, and if it does not exist, it will continue to look for methods in the parent class, and if it does not exist, it will look for the existence of an auto-matching template file. If a template file exists, the template output is rendered directly.
Therefore, an important process in application development is to define specific operations for different modules. An application that does not need to define a model class when it is not required to interact with the database, but must define an action controller. The definition of the action controller is simple, as long as you inherit the action base class, for example: Microfiber cloth

Copy the Code code as follows:


Class Useraction extends action{
}


If we want to execute the following URL
Http://servername/index.php/User/add
You need to add an Add method on it, for example
Collapse PHP code to copy content to clipboard

Copy the Code code as follows:


Class Useraction extends action{
Define an Add action method, noting that the operation method does not require any parameters
Public function Add () {
The logical implementation of the Add Action method
... bath Rug
$this->display (); Output Template page
}
}


The action method must be defined as the public type, or an error will occur. Also note that the name of the action method is not duplicated with the method of the built-in action class. The template file for the current operation is automatically positioned, and the default template file should be located in the tpl\default\user\add.html under the project directory.

The above describes the THINKPADE400578MDC thinkphp using modules and operational analysis, including the THINKPADE400578MDC aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.