This article describes the implementation of thinkphp3.x custom action, model and view. Share to everyone for your reference, specific as follows:
1, create the 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, and create the test.html template file under test;
3, the implementation of Url:http://localhost/xmall/index.php/test/index will appear test.html page content
4, during the operation of the error occurred:
(1) The t of test in the URL should be capitalized;
(2) display does not need to provide file extensions, the default is index
5, Attention matters:
(1) In order to facilitate debugging, should be added in the index.php entry file
Define ("App_debug", true);
(2) It is best to specify a default template in the configuration file (xmall/conf/config.php): ' Default_theme ' => ' default '
6, create the file under Xmall/lib/model UserModel.class.php
Class Usermodel extends model{
function test () {return
"123456";
}
}
7. Add New method in xmall/lib/action/testaction.class.php
Public Function test () {
$m =d ("User");
echo $m->test ();
}
8, the execution url:http://localhost/xmall/index.php/index/test, the page output 123456
9, note: Model filename to and model of the name has been, and in the call to distinguish case;
Add ' url_case_insensitive ' =>true,//url case-insensitive in xmall/conf/config.php
PS: Here recommend a few of the format of this site landscaping tools, I believe that we can use in future development:
PHP code online format Landscaping tools:
Http://tools.jb51.net/code/phpformat
JavaScript code Landscaping/compression/formatting/encryption Tools:
http://tools.jb51.net/code/jscompress
Online XML format/compression tools:
Http://tools.jb51.net/code/xmlformat
SQL code Online formatting Landscaping tools:
Http://tools.jb51.net/code/sqlcodeformat
More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Common Methods Summary", "Smarty Template Primer" and "PHP template technology Summary."
I hope this article will help you with the PHP program design based on thinkphp framework.