Search Marketing

   
   

Using an Array for Web Page Titles

Fri May 02, 2008 10:04 pm
<<     >>
Comments: 0 Views: 2487

This post is designed to encourage the use of separate and specific web page titles using PHP, without the need for a database. While this is not the only way, or best way to accomplish page titling, it is nonetheless a useful and easy to work with.

Lets assume you have a website with 5 pages.

Home
About
Products
Services
Contact

The goal is to present the visitor with unique titles for each page.

If you are using a scripting language like PHP to construct your documents then you might have made a simple page like the following.

<html>
<head>
<title><?= $call_title; ?></title>
</head>
<body>

<!-- web page navigation -->

<a href=”?page=home”>Home</a>
<a href=”?page=about”>About</a>
<a href=”?page=products”>Products</a>
<a href=”?page=services”>Services</a>
<a href=”?page=contact”>Contact</a>

<!-- place for content of pages -->

<?php

if(!$_GET['page'])
include "includes/home.php";
else
include "includes/$page.php";

?>

</body>
</html>

You essentially have six files.

index.php
/includes/home.php
/includes/about.php
/includes/products.php
/includes/services.php
/includes/contact.php

Begin with creating an array of the titles. For simplicity we will just use basic titles. You should conduct the proper marketing research to determine what will work best for your company.

$pages = array('home','about','products','services','contact');

$select_page = array_search($_GET['page'], $pages);

$new_title = array('Home Page', 'About Area', 'Product Pages', 'Our Services', 'Contact Us');

$call_title = $new_title[$select_page];

The code above would be placed at the top of index.php, above any html.

The finished version would look like this:

<?php

$pages = array('home','about','products','services','contact');

$select_page = array_search($_GET['page'], $pages);

$titles = array('Home Page', 'About Area', 'Product Pages', 'Our Services', 'Contact Us');

$call_title = $titles[$select_page];

?>

<html>
<head>
<title><?= $call_title; ?></title>
</head>
<body>

<!-- web page navigation -->

<a href=”?page=home”>Home</a>
<a href=”?page=about”>About</a>
<a href=”?page=products”>Products</a>
<a href=”?page=services”>Services</a>
<a href=”?page=contact”>Contact</a>

<!-- place for content of pages -->

<?php

if(!$_GET['page'])
include "includes/home.php";
else
include "includes/$page.php";

?>

</body>
</html>



Comments
Name:
*
URL: http: (ex. cnn.com)
Comment:
*
Number:
Math (22 + 3)
* required
SubCategories
Regular Expressions

© 2019 Christonium LLC

Christonium.com
|
Terms of Use
|
Privacy
ccc