博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
3.1.2 MVC模式和URL访问
阅读量:4583 次
发布时间:2019-06-09

本文共 2479 字,大约阅读时间需要 8 分钟。

本节课大纲:一、什么是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.phpclass IndexAction extends Action 继承Action类
show('hello-world'); }}http://localhost/thinkphp/index.php/Index/show访问Index 模块的show方法
show('hello-world'); } public function show(){ echo 访问了Index模块的show方法; }}接口传参:
show('hello-world'); } public function show(){ echo 访问了Index模块的show方法; echo "欢迎你".$_GET['name']"; }}http://localhost/thinkphp/index.php/Index/show?name=jjhttp://localhost/thinkphp/index.php/Index/show/name/jjhttp://localhost/thinkphp/index.php/Index/show/name/xxyyzz传递多个参数:
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
show('Hello world'); } public function test(){ $this->show('访问Index模块下的show方法'); }}访问Index模块下的test方法get传参:
show('Hello world'); } public function test(){ $this->show("欢迎你.$_GET[name]"); }}http://localhost:8080/thinkphp/index.php/Index/test/name/xxxhttp://localhost:8080/thinkphp/index.php/Index/test?name=yyy
show('Hello world'); } public function test(){ $this->show("欢迎你.$_GET[name].'你的年龄是'.$_GET[age]"); }}http://localhost:8080/thinkphp/index.php/Index/test?name=yyy&age=3321http://localhost:8080/thinkphp/index.php/Index/test/name/yyy/age/31313444//开启调试模式,关闭缓存 define('APP_DEBUG',true); REWRITE模式 开启REWRITE,

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6199814.html

你可能感兴趣的文章
关于Eclipse的unsupported major minor version 51.0 错误
查看>>
2014年目标
查看>>
weblogic启动后 登陆控制台特别慢的问题
查看>>
Spring加载resource时classpath*:与classpath:的区别
查看>>
映射“DataAdapter.TableMappings”
查看>>
Vue双向绑定
查看>>
activity生命周期
查看>>
IO流
查看>>
动画学习之Music图形绘制
查看>>
2019 2.15模拟赛
查看>>
扩展欧几里得
查看>>
基于H5 pushState实现无跳转页面刷新
查看>>
【Netty】第一个Netty应用
查看>>
OpenSSL中HMAC,MD5以及对称加密算法的应用
查看>>
如何在手机网站上添加百度地图(带搜索功能)
查看>>
js正则表达式应用
查看>>
web基础,用html元素制作web页面
查看>>
Ubuntu 16.04安装GIMP替代PS
查看>>
使用SmartQQ实现的智能回复(Web QQ协议)
查看>>
redis下的字符串处理
查看>>