Relationship between URL path access and Module Controller in ThinkPHP

Source: Internet
Author: User
This article mainly introduces the relationship between URL path access in ThinkPHP and the module controller. it is a very important technique for ThinkPHP program development. if you need it, refer to ThinkPHP.

The relationship between URL path access in ThinkPHP and the module controller is an important part in ThinkPHP program development. Mastering ThinkPHP skills is crucial to further learning ThinkPHP. The specific analysis is as follows:

Open the controller page:

UserAction. class. php // path: admin \ Lib \ Action \ here admin is the directory corresponding to the new project

We all know that the method in Action is the Public attribute by default, and the method of private attribute cannot be accessed, but the method of defining private attribute also has its significance.

The significance of defining private methods is as follows: you can write a method related to the user module here, but you do not want the original method to be too bloated. therefore, we can define a private implementation. if the verification specification changes, we only need to modify one of the methods. You don't have to find a bunch of code.

The sample code is as follows:

Class UserAction extends Action {function index () {echo 'this is the homepage';} function add () {$ this-> verify (); echo 'This is the method for writing data to the database';} private function verify () {echo 'This is the verification method ';}}

../Admin. php/User/add execution result:

This is the verification method. this is the method for writing data to the database.

I hope this article will help you with ThinkPHP programming.

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.