基于ThinkPHP的开发笔记1-注册功能(非分组模式)

借鉴以前发的许愿墙的代码,使用分组的模式开发。
一、建立项目文件夹,个人命名是antsclub
二、将最新版的TP拷贝到项目根目录
三、建立index.php并配置文件路径。此次功能的开发,将参考IKPHP的代码,可是目录结构仍是参考以前的许愿墙,考虑到不一样的Action已经能够把不一样的模块分开,因此暂时不用分组模式。 php

<?php
 define('APP_NAME', './antsclub');
 define('APP_DEBUG', TRUE);
 require('./ThinkPHP/ThinkPHP.php');
?>
访问localhost/antsclub,出现欢迎页面,说明建立成功。
注意设置APP_NAME,不使用分组模式的时候,APP_NAME设置为项目根目录,不然会认为是www(apache根目录),这样会致使__ROOT__, __PUBLIC__等地址也是从www目录开始,而不是项目根目录
四、修改./Lib/Action/IndexAction.class.php,输出个简单的首页,页面中只有一个到注册页面的超连接
<?php
class IndexAction extends Action {
    public function index(){
    	$str='<a href="'.U('/User/register','','').'">注册</a>';
    	$this->show($str,'utf-8');
    }
}
注意php中是用点来链接字符串,而不是+
五、创建./Lib/Action/UserAction.class.php, 新建register函数
<?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>
相关文章
相关标签/搜索