ThinkPHP 初级问题 调用Html

jiaxz 2015-12-20 03:49:29
我第一次用ThinkPHP,创建了一个index.php :
<?php
define('APP_NAME','app');
define('APP_PATH','./app/');
require 'ThinkPHP.php';
?>
然后修改了app\Lib\Action\IndexAction.class.php :
<?php
class IndexAction extends Action {
public function index(){
$this->display();
}
}
可以在网站中打开index.php ,可以调用\Tpl\index\index.html.

现在我想再建个user.php ,最终像index.php 那样,调用\Tpl\index\user.html,请问修改哪些代码?谢谢!
...全文
222 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Delphi小叮当 2015-12-21
  • 打赏
  • 举报
回复
也可以直接修改这个 $this->display();
a7478729 2015-12-20
  • 打赏
  • 举报
回复
也可以直接修改这个 $this->display();
misaka去年夏天 2015-12-20
  • 打赏
  • 举报
回复
只需要在IndexController.class.php方法里,再新建一个方法: public function user(){ $this->display(); } 最后在View/default/Index/新建一个user.html的文件。 3.2版本一下的thinkphp的view层可能和上面说的不一样,可以参考手册
李睿_Lee 2015-12-20
  • 打赏
  • 举报
回复
index.php是入口文件,只有一个,不用再建立user.php 只需要修改app\Lib\Action\IndexAction.class.php :
<?php
class IndexAction extends Action {
    public function index(){
$this->display();
    }

    public function user(){
        $this->display();
    }
}
访问时用index.php/Index/user这样的路径

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧