CodeIgniter Forums
Codeigniter redirects best approach to choose - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Choosing CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=8)
+--- Thread: Codeigniter redirects best approach to choose (/showthread.php?tid=84794)



Codeigniter redirects best approach to choose - AnatalGrowina - 11-10-2022

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