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

  • Home
  • SEARCH
  • 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 8917179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:25:37+00:00 2026-06-15T05:25:37+00:00

This is how I set header $this->output->set_status_header(‘404’); in controller: <?php class custom404 extends CI_Controller

  • 0

This is how I set header $this->output->set_status_header(‘404’); in controller:

<?php
class custom404 extends CI_Controller
{
    public function __construct()
    {
            parent::__construct();
    }

    public function index()
    {
        $this->output->set_status_header('404');
        $this->view_data['page_title'] = 'Page not found';
        $this->view_data['main_content'] = 'error404';
        $this->load->view('template', $this->view_data);
    }
}
?>

Then I need to somehow check status header 404 in the view?

Any advice beside sending another variable in $this->view_data?

  • 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-15T05:25:38+00:00Added an answer on June 15, 2026 at 5:25 am

    Create a file called MY_Output.php in your application/core folder with the following code:

    <?php
    
    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
    
    class MY_Output extends CI_Output {
    
        function set_status_header($code = 200, $text = '')
        {
            set_status_header($code, $text);
            $this->last_set_status_code = $code;
            return $this;
        }
    
        function get_status_header()
        {
            return $this->last_set_status_code;
        }
    
    }
    
    ?>
    

    You can now echo out the last status code you set like so:

    $this->output->set_status_header('404');
    echo $this->output->last_set_status_code; // outputs '404'
    // or get it like so:
    echo $this->output->get_status_header(); // outputs '404'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this controller set up for a login: <?php class Login extends Controller
this is really doing my nut..... all relevant PHP Output scripts set headers (in
How can I redirect in PHP with this setup below without getting header output
I got this cookie returned from web-server in Set-Cookie header: PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6; path=/,wordpress_test_cookie=WP+Cookie+check; path=/,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com; expires=Sun,
Is this defined? Or is it set with a header, similar to the HTTP-response?
If I set a far future expire header for this file (take note of
If you set the Content-Disposition header to attachment , this causes user-agents to always
I have a set of functions that I declare in a header like this:
This file is an output file whose first line is a header followed by
At the moment we set content-type in our responce headers, a bit like this...

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.