最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

thinkphp3.x自定义Action、Model及View的简单实现方法_php实例

来源:动视网 责编:小采 时间:2020-11-27 20:32:02
文档

thinkphp3.x自定义Action、Model及View的简单实现方法_php实例

thinkphp3.x自定义Action、Model及View的简单实现方法_php实例:本文实例讲述了thinkphp3.x自定义Action、Model及View的实现方法。分享给大家供大家参考,具体如下: 1、在xmall/Lib/Action中创建文件TestAction.class.php class TestAction extends Action{ function index(){
推荐度:
导读thinkphp3.x自定义Action、Model及View的简单实现方法_php实例:本文实例讲述了thinkphp3.x自定义Action、Model及View的实现方法。分享给大家供大家参考,具体如下: 1、在xmall/Lib/Action中创建文件TestAction.class.php class TestAction extends Action{ function index(){


本文实例讲述了thinkphp3.x自定义Action、Model及View的实现方法。分享给大家供大家参考,具体如下:

1、在xmall/Lib/Action中创建文件TestAction.class.php

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

2、在xmall/tpl下创建default文件夹,在default下创建Test文件夹,在Test下创建test.html模版文件;

3、执行URL:http://localhost/xmall/index.php/Test/index就会出现test.html页面的内容

4、在操作过程中出现的错误:

(1) URL中的Test的T要大写;

(2) Display不需要提供文件的扩展名,默认为index

5、注意事项:

(1) 为方便调试,应在index.php入口文件中添加

define("APP_DEBUG",true);

(2) 最好在配置文件(xmall/Conf/config.php)中指定默认模版:'DEFAULT_THEME' => 'default'

6、在xmall/lib/Model下创建文件UserModel.class.php

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

7、在xmall/Lib/Action/TestAction.class.php添加新方法

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

8、执行URL:http://localhost/xmall/index.php/Index/test,页面输出123456

9、注:Model文件名要与model的名称一直,并且在调用时区分大小写;

在xmall/conf/config.php中添加'URL_CASE_INSENSITIVE' =>true,//URL不区分大小写

PS:这里推荐几款本站的格式化美化工具,相信大家在以后的开发中能够用得上:

php代码在线格式化美化工具:
http://tools.php.com/code/phpformat

JavaScript代码美化/压缩/格式化/加密工具:
http://tools.php.com/code/jscompress

在线XML格式化/压缩工具:
http://tools.php.com/code/xmlformat

sql代码在线格式化美化工具:
http://tools.php.com/code/sqlcodeformat

更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《ThinkPHP常用方法总结》、《smarty模板入门基础教程》及《PHP模板技术总结》。

希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。

文档

thinkphp3.x自定义Action、Model及View的简单实现方法_php实例

thinkphp3.x自定义Action、Model及View的简单实现方法_php实例:本文实例讲述了thinkphp3.x自定义Action、Model及View的实现方法。分享给大家供大家参考,具体如下: 1、在xmall/Lib/Action中创建文件TestAction.class.php class TestAction extends Action{ function index(){
推荐度:
标签: php thinkphp view
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top