zoukankan      html  css  js  c++  java
  • MVC模式和URL访问

    三、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
    

  • 相关阅读:
    MyEclipse for Spring 10.0: GWT 2.1 and Spring Scaffolding
    redis 协议
    Eclipse项目编译
    urlencode
    Firefox浏览器设置字符编码格式
    怎么从一台电脑的浏览器输入地址访问另一台电脑服务器(WAMP服务器已搭建,PHPSTORM装好了)...
    Tplink路由器怎么设置端口映射 内网端口映射听语音
    5.04 toArray()有一个问题须要解决一下
    WCF服务编程读书笔记(4):实例管理
    maven常用命令介绍
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349656.html
Copyright © 2011-2022 走看看