Simple implementation of thinkphp3.x custom Action, Model, and View, thinkphp3.xaction

Source: Internet
Author: User

Simple implementation of thinkphp3.x custom Action, Model, and View, thinkphp3.xaction

This document describes how to implement thinkphp3.x custom actions, models, and views. We will share this with you for your reference. The details are as follows:

1. Create the file TestAction. class. php In xmall/Lib/Action.

class TestAction extends Action{   function index(){    $this->display("test");   }}

2. Create a ultultfolder under xmall/tpl, create a test folder under default, and create a test.html template file under test;

3. Run the URL: http: // localhost/xmall/index. php/Test/indexto display the content of the test.html page.

4. Errors During Operation:

(1) The T of Test in the URL should be capitalized;

(2) Display does not need to provide the file extension. The default value is index.

5. Notes:

(1) To facilitate debugging, add the index. php entry 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 the UserModel. class. php file under xmall/lib/Model.

class UserModel extends Model{   function test(){     return "123456";   }}

7. Add a new method in xmall/Lib/Action/TestAction. class. php.

public function test(){   $m=D("User");   echo $m->test();}

8. Run the URL: http: // localhost/xmall/index. php/Index/test. The page output is 123456.

9. Note: The name of the Model file must be the same as that of the model, and the Model name must be case sensitive during the time zone call;

Add 'url _ CASE_INSENSITIVE '=> true to xmall/conf/config. php. // The URL is case insensitive.

PS: We recommend several formatting and beautification tools on this site. I believe you can use them in future development:

Php code online formatting and beautification tools:
Http://tools.jb51.net/code/phpformat

JavaScript code beautification/compression/formatting/encryption tools:
Http://tools.jb51.net/code/jscompress

Online XML formatting/compression tools:
Http://tools.jb51.net/code/xmlformat

SQL code online formatting and beautification tools:
Http://tools.jb51.net/code/sqlcodeformat

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.