三、ThinkPHP的MVC对应的目录 //了解
M 项目目录/应用目录/Lib/Model
C:wampwww hinkphpHomeLibModel
V 项目目录/应用目录/Tpl
C:wampwww hinkphpHomeTpl
C 项目目录/应用目录/Lib/Action
C:wampwww hinkphpHomeLibAction
命名: xxAction.class.php
http://localhost:8080/thinkphp/index.php/Index/index 访问Index模块下的index 方法
Administrator@OEM-20140503SYK /cygdrive/c/wamp/www/thinkphp/Home/Lib/Action
$ dir
IndexAction.class.php
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-
family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-
size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script
type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
}
}
访问 http://127.0.0.1:8080/thinkphp/
实际上访问的是
IndexAction.class.php
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
#$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-
family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-
size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script
type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
echo "hello world";
}
}
http://127.0.0.1:8080/thinkphp/index.php/Index/index
工程名字/入口文件/模块/方法
五、url的4种访问方式 //重点!
1.PATHINFO 模式 -- 重点!!!!!!
http://域名/项目名/入口文件/模块名/方法名/键1/值1/键2/值2
http://localhost/thinkphp/index.php/Index/show
传参:
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
#$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-
family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-
size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script
type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
echo "hello world!!!!!";
}
public function show(){
echo "欢迎你".$_GET['name'];
}
}
http://127.0.0.1:8080/thinkphp/index.php/Index/show?name=test
http://127.0.0.1:8080/thinkphp/index.php/Index/show/name/test
http://127.0.0.1:8080/thinkphp/index.php/Index/show/name/test/age/18
//3.开启调试模式
define('APP_DEBUG',true); 避免缓存
2.普通模式
http://域名/项目名/入口文件?m=模块名&a=方法名&键1=值1&键2=值2
http://127.0.0.1:8080/thinkphp/index.php/Index/show?name=test&age=18