PHP Keyword Formatting Utility Class

Status
Not open for further replies.

maxor

New member
Jun 1, 2007
178
2
0
Arizona, USA
www.npboards.com
I wrote this PHP class for a landing page I recently created where I needed to do some dynamic keyword insertion. It's not much, but it might save you some time.

Here's a quick guide for how to use it.

Code:
<?php

  // Print out a human readable version of the keyword (useful for headlines)
  // http://www.example.com/?kw=debt%20consolidation%20solutions
  
  echo '<h2>' . KeywordUtil::humanize_keyword($_GET['kw']) . '</h2>';
  // prints: <h2>Debt Consolidation Solutions</h2>

  // Print out a lower case version of the string (useful for meta tags etc)
  // http://www.example.com/?kw=debt%20consolidation%20solutions

  echo '<meta name="keywords" content="'. KeywordUtil::humanize_keyword($_GET['kw']) . '" />';
  // prints: <meta name="keywords" content="debt consolidation solutions" />

  // Print out a lower case version of the string, separated by underscores 
  // (useful for ids, etc)
  // http://www.example.com/?kw=debt%20consolidation%20solutions

  echo '<body id="'. KeywordUtil::humanize_keyword($_GET['kw']) . '">';
  // prints: <body id="debt_consolidation_solutions">

?>

  • A Class constant specifies a default keyword
  • PHP5 is required
  • It's not thoroughly tested, but should work alright

I'll try to keep this thread updated as time goes on and I add to the class.
 

Attachments



Status
Not open for further replies.