借鉴以前发的许愿墙的代码,使用分组的模式开发。
一、建立项目文件夹,个人命名是antsclub
二、将最新版的TP拷贝到项目根目录
三、建立index.php并配置文件路径。此次功能的开发,将参考IKPHP的代码,可是目录结构仍是参考以前的许愿墙,考虑到不一样的Action已经能够把不一样的模块分开,因此暂时不用分组模式。 php
<?php define('APP_NAME', './antsclub'); define('APP_DEBUG', TRUE); require('./ThinkPHP/ThinkPHP.php'); ?>访问localhost/antsclub,出现欢迎页面,说明建立成功。
<?php class IndexAction extends Action { public function index(){ $str='<a href="'.U('/User/register','','').'">注册</a>'; $this->show($str,'utf-8'); } }注意php中是用点来链接字符串,而不是+
<?php class UserAction extends Action{ public function register(){ echo "register function"; } }六、修改IndexAction,调用模板页
<?php class IndexAction extends Action { public function index(){ $this->display(); } }七、建立模板页,./Tpl/Index/index.html
<html> <head> <title> </title> </head> <body> <a href='{:U("/User/register","","")}'>注册</a> </body> </html>