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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:24:43+00:00 2026-05-17T22:24:43+00:00

I am Trying to get the page title ( <title>bla..bla..bla..</title> ) to be changable

  • 0

I am Trying to get the page title (<title>bla..bla..bla..</title>) to be changable in php with a multi-file layout like so:
Functions.php is included into index.php, then get_header() is called from functions.php to include the page header.php the title tag is inside the header file. I would like to be able to set the title from index.php how can i do this?

For examle this is what i have tried:
Index.php:

<? require_once('includes/functions.php'); global $t; $t = '/home/s0urc3'; get_header();?>

<div id="main">

    <h2><a href="NEEDED" rel="bookmark" title="Permanent Link to NEEDED">NEEDED</a></h2>


    <p class="postmeta"><a href="<?php page_url(yes)?>" class="readmore">Permalink</a> | <span class="date">Revision Date</span></p>

        <p>CONTENT AND CRAP</p>

    <!-- main ends -->  
</div>
<?php /*test*/echo($title);/*test*/ get_footer();?>

Header.php:

<?php //include('functions.php')?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<? title('$t')?>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<?php get_theme_css()?>
</head>

<body>
<!-- wrap starts here -->
<div id="wrap">

    <!--header -->
    <div id="header">               
        <h1 id="logo-text"><a href="<?php echo (HOME)?>"><img src="<?php get_url('images/Logo.png')?>" alt="S0URC3"><!-- S0URC3 --></a></h1></div>  

<p id="intro">
        Just another poorly coded website!
        </p>
        </div>
        <div id="nav">
            <!-- <div id="navi"><div id="menu" class="fixed"> -->
            <ul class="">
            <li class=""><a href="http://s0urc3.ismywebsite.com">Home</a></li>
            <li class=""><a href="http://blog.s0urc3.ismywebsite.com">Blog</a></li>
            <li class=""><a href="http://forums.s0urc3.ismywebsite.com">Forums</a></li>
            <li class=""> <a href="mailto:ellisgeek@gmail.com?subject=Comments">Comments</a></li>
            <!--<li class="">Clans</li>-->
            <li class=""><a href="http://astro.s0urc3.ismywebsite.com">-astro-</a></li>
            <!--<li class=""><a href="#">Inspiration</a></li>
            <li class=""><a href="#">Resources</a></li>         
            <li class=""><a href="#">Tutorials</a></li>         
            <li class=""><a href="#">WordPress</a></li>-->          
        </ul><!-- </div></div> -->

        </div>                  
    <!--header ends-->                  
    </div>

    <!-- content-wrap starts -->
    <div id="content-wrap">

Functions.php:

<?php
require_once('constants.php');
  //===============//
 //Start Functions//
//===============//

//Gets a file from the domain http://files01.s0urc3.ismywebsite.com/
function get_url($file)
{
echo (FILE_ROOT . $file);
}

//gets the url of the theme
function get_theme_css() {echo('<link rel="stylesheet" href="' . FILE_ROOT . 'colourise/style.css" type="text/css" />');}

function get_header() {require_once('includes/header.php');}

function get_footer() {require_once('includes/footer.php');}

//Gets the URL of the current page
function page_url($p)
{
    $s = empty($_SERVER["HTTPS"]) ? ''
        : ($_SERVER["HTTPS"] == "on") ? "s"
        : "";
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
    $port = ($_SERVER["SERVER_PORT"] == "80") ? ""
        : (":".$_SERVER["SERVER_PORT"]);
        if ($p == 'yes')
  echo ($protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']);
else
    return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2)
{
    return substr($s1, 0, strpos($s1, $s2));
}

//gets the year
function cur_year() {echo (YEAR);}

function ads($code) {echo('<script type="text/javascript" src="http://links.ismywebsite.com?i='. $code .'"></script>');}

function title($title)
{echo('<title>Index Of: '.$title.'</title>');}
  //=============//
 //End Functions//
//=============//
?>

P.S. I only am including functions once all functions are available in the header and footer when functions.php is called in index.php

  • 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-17T22:24:43+00:00Added an answer on May 17, 2026 at 10:24 pm

    First, the file header.php is being included from within a function, so it does not have access to the global variable $t. You will need to do one of the following:

    In functions.php:

    function get_header() {
        global $t;
        require_once('includes/header.php');
    }
    

    Or, in header.php:

    <?php //include('functions.php')
    global $t;
    ?>
    <!DOCTYPE html>
    <!-- etc -->
    

    That way, the variable you have declared will be available to the function’s local variable scope.

    Second, you need to call the function with either double quotes or no quotes at all. Single quotes will not parse a variable.

    Right

    • title($t);
    • title("$t");
    • title("{$t}");

    Wrong

    • title('$t');

    Here is the PHP Manual Page on the String datatype — be sure to check out single quoted strings versus double quoted strings.

    Nitpicky Things:

    • You should always use the full opening tags (<?php), and not the short open tags (<?)
    • Your functions, like title(), should always return a value, and you can echo that, rather than echoing directly from inside the function.
    • The strleft() function you implemented, though clever, already exists. See: strstr() Actually, this function does the opposite of what you want; I mis-remembered what it did. Carry On. EDIT AGAIN: No, apparently I was right, you pass the optional third parameter as true. You should generally use functions that already exist because, with certain exceptions, they will be faster.
      • A Notable exception to this rule is array_rand()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My db table looks like that I'm trying to get page title and content
I'm trying to get the title of a page in an iFrame. I did
I'm trying to get an html page to display an XML file formatted with
I am trying to get a page title from page source of different pages.
I'm trying to get the plain html page title with javascript. I use firefox
I am trying to get another page to call into a div on a
I'm trying to get a page title to show up when outputting a pdf
Just trying to get into JQueryMobile. I want to do something simple like putting
I am trying to get page title on every page using new Firefox add-on
I am trying to get my current page id and title for reference but

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.