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
https://forums.phpfreaks.com/topic/108839-solved-theory-question/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.