Thinkphp3.x a simple implementation of custom action, model, and view

Source: Internet
Author: User
This article mainly introduces the simple implementation method of thinkphp3.x custom action, model and view, and analyzes the specific steps of thinkphp3.x custom model, view and controller with the example form, and the related implementation skills, the friends who need can refer to

This article describes the implementation of thinkphp3.x custom action, model, and view. Share to everyone for your reference, as follows:

1. Create a file in Xmall/lib/action TestAction.class.php

Class Testaction extends action{   function index () {    $this->display ("Test");}   }

2, create the default folder under XMALL/TPL, create the test folder under Default, create the test.html template file under test;

3, the execution Url:http://localhost/xmall/index.php/test/index will appear test.html page content

4. Errors that occur during the operation:

(1) The t of test in the URL should be capitalized;

(2) display does not need to provide the file extension, the default is index

5. Precautions:

(1) For the convenience of debugging, should be added in the index.php entrance file

Define ("App_debug", true);

(2) It is best to specify the default template in the configuration file (xmall/conf/config.php): ' default_theme ' = ' ' Default '

6. Create a file under Xmall/lib/model UserModel.class.php

Class Usermodel extends model{   function test () {     return ' 123456 ';}   }

7. Adding new methods in xmall/lib/action/testaction.class.php

Public Function test () {   $m =d ("User");   echo $m->test ();}

8, Execution url:http://localhost/xmall/index.php/index/test, page output 123456

9, Note: Model file name with the model name has been, and in the invocation of case-sensitive;

Adding ' url_case_insensitive ' =>true,//url is not case-sensitive in xmall/conf/config.php

Related Article

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.