The relationship between URL path access and module controller in thinkphp, thinkphpurl_php tutorial

Source: Internet
Author: User

The relationship between URL path access and module controller in thinkphp, Thinkphpurl


The relationship between URL path access and module controller in thinkphp is a very important part of thinkphp program development. Mastering this skill is very important for further learning thinkphp. The specific analysis is as follows:

To open the Controller page:

UserAction.class.php//path: admin\lib\action\ Here the admin for the new project corresponding to the directory

We all know that the method in action defaults to the public property, the method of the private property is inaccessible, but the method that defines the private property has its meaning.

The meaning of the private method is defined: it is mainly embodied in the ability to write a method related to the user module here, but you do not want the original method is too bloated, so we can define a private to implement, if the validation specification changes, only need to change one of the methods in the line. No need to find a lot of code to find.

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 of writing data to the database '; } Private Function Verify () {  echo ' This is the method of validation ';}}

.. /admin.php/user/add Execution Results:

This is the way to verify that this is the way to write data to the database

I hope this article is helpful to everyone thinkphp program design.


thinkphp URL path Access Pattern related issues

It can be obtained with $_get.
As an example,
Index.php/action/function/id/2

$_get[cation] is function

$_get[id] is 2

Do you understand me? It's just a change of form, a value that can be taken.

URL Access for thinkphp

The main entry file is missing. The way you access this is in the state of rewriting.
To check the settings file:
"Url_model" =>2, check Apache settings and root rewrite files
or change to 1, using Pachinfo access.

http://www.bkjia.com/PHPjc/868227.html www.bkjia.com true http://www.bkjia.com/PHPjc/868227.html techarticle The relationship between URL path access and module controller in thinkphp, and the relationship between URL path access and module controller in Thinkphpurl thinkphp is a very important link in thinkphp program development ...

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