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