質問

i saw this function 'is_post' at this website:

http://www.kylenoland.com/a-comprehensive-guide-to-securing-codeigniter-2-x-with-ben-edmunds-ion-auth/

class MY_Controller extends CI_Controller
{
    public function is_post()
    {
        return $_SERVER['REQUEST_METHOD'] == 'POST' ? TRUE : FALSE;
    }
}

May i know the correct way to use this function and how? thanks. regards, zs

役に立ちましたか?

解決

One of the advantages of using your own parent controller is that the common checks can be checked at central position. so when you are creating/defining a controller, you can inherit from your own controller, like below to use parent class methods:

class User_Controller extends MY_Controller
{
    public function login()
    {
        if($this->is_post()){
            //login check and redirect if successfull.
        }
        $this->load->view("login");
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top