看了tp,只是了解了一点皮毛,哎,加油加油了……
<?php //建立一个文件,文件中包含如下内容 define('THINK_PATH','ThinkPHP/');//ThinkPHP路径 define('APP_NAME','php');//项目名称 define('APP_PATH','.');//项目路径 require(THINK_PATH."/ThinkPHP.php"); $APP=new App();//实例化,系统会自动创建各个文件目录 $APP->run(); ?>
IndexAction.class.php部分:
<?php class IndexAction extends Action{ public function index(){//默认访问的控制器方法,可以设置 $php100=new PhpModel();//实例化模块 需在Model下建一个PhpModel.class.php $list=$php100->findAll();//查询数据库 $this->assign("list",$list);//传值到index.html $this->assign("title","ljf学习thinkphp"); $this->display();//显示index.html } } ?>
PhpModel.class.php部分,注意名字
<?php class PhpModel extends Model{ } ?>
index.html部分 建立在tpl/default/index/index.html下
<title>{$title}</title> <volist name="list" id="vo"> {$vo.title} {$vo.content}<br/> </volist>