문제

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