MVCモードとURLアクセス

2299 ワード

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