本节课大纲:
一、什么是MVC //了解
M -Model 编写model类 对数据进行操作 使用Model类 来操作数据
V -View 编写html文件,页面呈现
C -Controller 编写类文件(UserAction.class.php) 二、ThinkPHP的MVC特点 //了解
三、ThinkPHP的MVC对应的目录 //了解
M 项目目录/应用目录/Lib/Model C:\wamp\www\thinkphp\Home\Lib\Model V 项目目录/应用目录/Tpl C:\wamp\www\thinkphp\Home\Tpl C 项目目录/应用目录/Lib/Action C:\wamp\www\thinkphp\Home\Lib\Action 命名: xxAction.class.php http://localhost:8080/thinkphp/index.php/Index/index 访问Index模块下的index 方法 四、url访问C //了解 五、url的4种访问方式 //重点!
1.PATHINFO 模式 -- 重点!!!!!!
http://域名/项目名/入口文件/模块名/方法名/键1/值1/键2/值2 http://localhost/thinkphp/index.php/Index/show 2.普通模式
http://域名/项目名/入口文件?m=模块名&a=方法名&键1=值1&键2=值2 3.REWRITE模式
http://域名/项目名/模块名/方法名/键1/值1/键2/值2 4.兼容模式
http://域名/项目名/入口文件?s=模块名/方法名/键1/值1/键2/值2 http://localhost/thinkphp/ 访问的是index.php 主入口文件 http://localhost/thinkphp/index.php/Index/index 模块/方法 C:\wamp\www\thinkphp\Home\Lib\Action 默认模块IndexAction.class.php 比如要创建用户模块 UserAction.class.php class IndexAction extends Action 继承Action类 <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('hello-world');
}
} http://localhost/thinkphp/index.php/Index/show 访问Index 模块的show方法 <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('hello-world');
}
public function show(){
echo 访问了Index模块的show方法;
}
} 接口传参: <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('hello-world');
}
public function show(){ echo 访问了Index模块的show方法;
echo "欢迎你".$_GET['name']";
}
} http://localhost/thinkphp/index.php/Index/show?name=jj http://localhost/thinkphp/index.php/Index/show/name/jj http://localhost/thinkphp/index.php/Index/show/name/xxyyzz 传递多个参数:
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('hello-world');
}
public function show(){ echo 访问了Index模块的show方法;
echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
}
} http://localhost/thinkphp/index.php/Index/show/name/xxyyzz/age/22 <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('Hello world');
} public function test(){
$this->show('访问Index模块下的show方法');
}
} 访问Index模块下的test方法 get传参: <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('Hello world');
} public function test(){
$this->show("欢迎你.$_GET[name]");
}
} http://localhost:8080/thinkphp/index.php/Index/test/name/xxx http://localhost:8080/thinkphp/index.php/Index/test?name=yyy <?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
$this->show('Hello world');
} public function test(){
$this->show("欢迎你.$_GET[name].'你的年龄是'.$_GET[age]");
}
} http://localhost:8080/thinkphp/index.php/Index/test?name=yyy&age=3321 http://localhost:8080/thinkphp/index.php/Index/test/name/yyy/age/31313444 //开启调试模式,关闭缓存 define('APP_DEBUG',true); REWRITE模式
开启REWRITE,

3.1.2 MVC模式和URL访问的更多相关文章

  1. MVC模式和URL访问

    一.什么是MVC //了解 M -Model 编写model类 对数据进行操作 使用Model类 来操作数据 V -View 编写html文件,页面呈现 C -Controller 编写类文件(Use ...

  2. ThinkPHP 3 MVC模式和URL访问

    一.什么是MVC                 //了解    M -Model 编写model类 对数据进行操作    V -View  编写html文件,页面呈现    C -Controlle ...

  3. phpcms V9 MVC模式 与 URL访问解析

    [1]URL访问解析 观察访问网页时的网址,可以得出模块访问方法,如下示例: http://www.abcd.com.cn/phpcms/index.php?m=content&c=index ...

  4. phpcms(1)phpcms V9 MVC模式 与 URL访问解析(转)

    [1]URL访问解析 观察访问网页时的网址,可以得出模块访问方法,如下示例: http://www.abcd.com.cn/phpcms/index.php?m=content&c=index ...

  5. [ThinkPHP]MVC模块和URL访问

    ## ThinkPHP 3 MVC模式和URL访问#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲: 一.什么是MVC                 // ...

  6. 2016/5/6 thinkphp ①框架 ② 框架项目部署 ③MVC模式 ④控制器访问及路由解析 ⑤开发和生产模式 ⑥控制器和对应方法创建 ⑦视图模板文件创建 ⑧url地址大小写设置 ⑨空操作空控制器 ⑩项目分组

    真实项目开发步骤: 多人同时开发项目,协作开发项目.分工合理.效率有提高(代码风格不一样.分工不好) 测试阶段 上线运行 对项目进行维护.修改.升级(单个人维护项目,十分困难,代码风格不一样) 项目稳 ...

  7. ASP.Net MVC开发基础学习笔记:一、走向MVC模式

    一.ASP.Net的两种开发模式 1.1 ASP.Net WebForm的开发模式 (1)处理流程 在传统的WebForm模式下,我们请求一个例如http://www.aspnetmvc.com/bl ...

  8. [ASP.NET MVC 小牛之路]01 - 理解MVC模式

    本人博客已转移至:http://www.exblr.com/liam  PS:MVC出来很久了,工作上一直没机会用.出于兴趣,工作之余我将展开对MVC的深入学习,通过博文来记录所学所得,并希望能得到各 ...

  9. ASP.Net MVC开发基础学习笔记(1):走向MVC模式

    一.ASP.Net的两种开发模式 1.1 ASP.Net WebForm的开发模式 (1)处理流程 在传统的WebForm模式下,我们请求一个例如http://www.aspnetmvc.com/bl ...

随机推荐

  1. matlab三维画图

    matlab三维画图主要有三个命令:plot3命令.mesh命令和surf命令. plot3 plot3是三维画图的基本函数,绘制的是最为主要的3D曲线图,最主要的调用格式是: plot3(X,Y,Z ...

  2. android5.0(Lollipop) BLE Peripheral深入理解系统篇之提高篇

    上一篇文章讲到了广播之前系统需要进行的准备工作,那接下来我们就来真正的启动广播. 首先还是先看一下上一篇文章结束的地方: @Override public void onClientRegistere ...

  3. GridView点击空白地方事件扩展

    我们通常在ListView或者GridView响应点击Item事件,但很多时候我们同样也 希望监听到点击空白区域的事件来做更多的处理.本文以GridView为例给出一个实现 的方法,扩展GridVie ...

  4. hdoj 1286 找新朋友 【数论之欧拉函数】

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  5. poj3278Catch That Cow(BFS)

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 37094   Accepted: 11466 ...

  6. sql: sybase 和 oracle 比较

    1. sybase 和 oracle 比较 http://blog.itpub.net/14067/viewspace-1030014/ Oracle采用多线索多进程体系结构 Sybase采用单进程多 ...

  7. C#中System.Globalization.DateTimeFormatInfo.InvariantInfo怎么用

    原文  C#中System.Globalization.DateTimeFormatInfo.InvariantInfo怎么用 在开发的时候,碰到下面这样一个问题: 在程序中显示当前系统时间,但是有一 ...

  8. C++ template error: undefined reference to XXX

    一般来说,写C++程序时推荐“类的声明和实现分离”,也就是说一个类的声明放在example.h文件中,而这个类的实现放在example.cpp文件中,这样方便管理,条理清晰. 但是如果类的声明用到了模 ...

  9. 炮塔郝梦主solo

    尊重开发人员的工作,转载时请注明出处:http://blog.csdn.net/haomengzhu/article/details/31885287 或许你会由于它爱上dota: 或许你会由于它爱上 ...

  10. u-boot的nand驱动写过程分析

    从命令说起,在u-boot输入下列命令: nand write 40008000 0 20000 命令的意思是将内存0x40008000开始的部分写入nand,从nand地址0开始写,写入长度是0x2 ...