记录一下cakephp中的方法调用和参数传递

比如,当这么写的时候:http://localhost/cakephp2/posts/delete/1则可以调用postscontroller下面的delete方法,出给的参数为1

那么postscontroller里面应该有如下方法:

public function delete($id){
     $this->set("id",$id);
     /*指定该方法的模板*/
     $this->render();
    }

上面的方法中,模板的名称和方法的名称采取了一致,如果想要别的名字或者路径下的模板的话,则可用如下的方法:

  1. $this -> viewPath = ‘accounts’;  
  2. $this -> render(‘edit’);  

你可能感兴趣的:(controller,cakephp)