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 6076975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:07+00:00 2026-05-23T10:40:07+00:00

I have a header.php I’m loading in my controllers for every page. However I

  • 0

I have a header.php I’m loading in my controllers for every page. However I want to have dynamic titles for each page. My idea was to pass a $title variable into the view as I’m loading it:

//Home Controller
function index()
{

    $data['title'] = "Dynamic Title";

    $this->load->view('header', $data);
    $this->load->view('layouts/home');
    $this->load->view('footer');

}

and then check for the $title variable in my header.php

<title>
    <?php if ($title)
        { 
            echo $title; 
        }
    else
        { 
            echo 'Default Title'; 
        }
    endif; ?>       
</title>

However this doesn’t work and I get a blank page. I think it is my syntax for the header.php but I can’t figure out why.

  • 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-05-23T10:40:07+00:00Added an answer on May 23, 2026 at 10:40 am

    Well I would try doing a var dump of $title in the view, just to see if it’s getting passed at all.

    Also, you don’t need “endif;” since you’re ending the if statement with the last curly brace.

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

Sidebar

Related Questions

In my rootfolder/xxx/header.php page have <title>some text</title> . I want to search as like
I have a html_headers.inc.php script that I want to include in every script on
Simply. I have an empty page looking like <?php include(header.php); include(footer.php); ?> That gives
I have a header.php and a footer.php file being included on the same page,
i have a web page with a fix header included by a simple include(header.php)
I have a members.php page/file in which i want logged in users to see
its a little bit hard to understand. in the header.php i have this code:
I have a problem with php header redirect. I already spent hours trying to
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;
I know in PHP, it sends the X-Powered-By header to have the PHP version.

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.