Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:15:12+00:00 2026-06-11T15:15:12+00:00

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

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:15:13+00:00Added an answer on June 11, 2026 at 3:15 pm

    I suggest using redirect() as it’s easy to change HTTP response code later, if you will need it, as well as making some of them to be refresh type.

    You can always override the helper if you’ll find it necessary to change all your redirects later and you’ll even have ability to add some logic to them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 functions/methods in the same controller in CodeIgniter like this: public function
How can i send two Model from controller to view using same action
I would like to have 4 actions with the same name (controller methods may
How can in controller redirect with post same data like this do form <form
I have a universal app, where I am sharing the same controller for a
I want to save the state of my view controller. I searched and found
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I am using the Page Controller pattern. How could I use the same controller
I would like to store different objects in the same controller content array and
I want to display different types of objects in the same ajax called controller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.