Jump to content

[SOLVED] Theory Question


bruckerrlb

Recommended Posts

I am about to do something I've never even thought about, and I'm trying to think how I can do this, but have no idea.

 

I created my website in php, and am using the include("header.php"); for all of my pages, and this ultimately goes to my header file, and this is great, because I can keep my stylesheets and what not in there. The problem lies in the title tag, right now all of my pages (about 11) have the same title, and I need to change this to optimize the site for the search engines. Does anyone know how I can have my include statement and yet custom title tags? Is this even possible? I am pretty sure it is, just don't know how.

Link to comment
Share on other sites

Yeah, just define, say, $title before you include the header file. Then echo out that, or ,if it's not been set, a default title. So, something like this:

 

Any page:

<?php
$title = 'Custom title for this page';
include('header.php');
?>

header.php

<?php
if(!isset($title)){
$title = 'Default title';
}
//echo out title and other header information
?>

 

Remember, an include is like just taking the contents of your included page and running it as if that code were in the page already.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.