PHPBuilder - Revisited: Build Dynamic Pages With Search Engines in Mind Page 3



RSS Twitter
Articles Tricks And Hacks

Revisited: Build Dynamic Pages With Search Engines in Mind - Page 3

by: Tim Perdue
|
July 30, 2000

Let's go into more detail now:

<?php

//sample shared.inc file

//set up database connections
//any global variables for background
//      colors or path names

function site_header($title) {

    
//contains common HTML
    //for the header
    
echo '<HTML>
        <HEAD>
        <TITLE>PHPBuilder.com - '
.$title.'</TITLE>';

    
//set up metatags
    //take out "the", "and" and "a"
    //a truly gifted developer would use 
    //a great Regular Expression here
    
$keywords=str_replace("the ",'',strtolower($title));
    
$keywords=str_replace("a ",'',$keywords);
    
$keywords=str_replace("and ",'',$keywords);
    
$keywords=str_replace("\"",'',$keywords);

    
//make the string comma-separated
    
$meta_array=explode(' ',$keywords);
    
$meta_words=implode($meta_array,', ');

    echo 
'
        <META NAME="KEYWORDS" CONTENT="PHP, '
.$meta_words.'">
        <META NAME="DESCRIPTION" CONTENT="PHP Developer, Web Developer, '
.$title.'">
    '
;

    echo 
'</HEAD>

    <BODY TEXT="#000099" BGCOLOR="#FFFFFF">'
;
}

function 
site_footer() {

    
//contains common html
    //for the footer

    
echo '</BODY></HTML>';

}

?>
There, now the site_header() function prints out the usual stuff + meta tags that are built from the $title string that you pass in. For best results, use a descriptive title on your pages.
On the next page, I'll show you you how to use the URL string to create a hierarchy.

« Previous Page
1
|
2
|
3
|
4
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Tim Perdue

Comment:



Comment:

(Maximum characters: 1200). You have characters left.