Welcome Guest, Not a member yet? Register   Sign In
Codeigniter redirects best approach to choose
#1

In the same controller i have found there are two ways to redirect.

Class Home extends mY_Controller{

    public $view;
    public $redirect;
    function first_method
    {
        $this->view =  FALSE;
        //  $this->second_method();
        //  redirect('Home/second_method');           
    }

    function second_method()
    {
        echo 'Second one';
    }     
}
I want to know which is the best approach also i have a redirect method in the my_controller if certain conditions do not match redirect the user using redirect variable just for simplicity i am posting this

<?php
class MY_Controller extends CI_Controller
{
    protected $data;

    function __construct()
    {
        parent::__construct();
    }

    public function _remap($method, $parameters)
    {
        if($this->view === FALSE)
        {
            redirect($this->redirect);
        }else{
            $this->load->view('my_view');
        } 

    }

Using the first method i am unable to access the second line
Reply




Theme © iAndrew 2016 - Forum software by © MyBB