BMagicSEO PHP Class
General description
BMagic SEO Class was specially designed for PHP programmers that makes custom solutions and needs to dinamically or in admin area create SEO links, special fields (page titles, meta description, meta keyword) and other "need to be clean text" enviroments (like XML feeds).
The main features are :
- Generate your web-safe and friendly SEO links for your website !
- Generate a limited list of keywords from a text
- Create friendly and web safe meta tags for your pages, from your dinamically created content.
BMagicSeo PHP Class can be used in many ways :
You can install the class to dinamically clean your client stored content at output (for example just take the article description, on page load and create the meta description).
Or you can install the class only in your backend, and create the special fields on submit (when a product new title is submitted, just generate the title tag and store them together in the database).
The class was tested and used by me in very "unsafe" enviroments, I worked with screwed products descriptions, with non-ascii characters, meta tags and in more then one language, anyway this class will do the following for you :
- cut off all double (or multiple) whitespaces, new lines and tabs
- replace all the diacritics (from Romanian, French, German, Spanish, Hungarian) to regular Ascii letters
- Remove prepositions (from your own list) from links and keyword list, make your words count
- Delete all non alpha-numerics characters, or transform them to html entities !
- delete all non-ascii (hidden) characters
- trim the text
- lowercase your links (and smart lower case the texts, only the first letter from a sentence is uppercase)
- delete all the slashes (stripslashes)
- dynamic separator character (usual hyphen) for your links
- remove all PHP and HTML tags from your text
- dinamycally limit the characters limit. The text will be cut at Sentence level (or word) so the description will still make sense.
The class can be used for other functions too, like calculate the words density for SEO analysis, this function can be extended to entire full website scans.
BMagicSEO can be instantied, so you can have multiple settings for multiple sections of your website. The options are :
- prop : Array of prepositions and words that will be replaced from text (single letter words will be automatically replaced.)
- del (string) : Word delimitator used in links, usually hyphen or underscore.
- trim (enabled/disabled): Trim the whitespaces from start and end of the text. (Recommended)
- lower (enabled/disabled) : Transform the text to lowercase. (Recommended). The link will completely be transformed to lowercase, but the text will be "This style.", as in only the First letter uppercase, per sentence
- prep (enabled/disabled) : delete the words defined in the prop array, or not.
- special (enabled/disabled) : Remove all non alpha numeric caracters from the text. If is false, in _link the caracters will be url-encoded, and in _text and _keys functions will be transformed to html entities.
- tags (enabled/disabled) : Remove all the PHP and HTML tags (even images and JScripts). Keep the important (SEO) text clean and safe.
- spaces (enabled/disabled) : Deletes the double (and multiple) spaces and tabs. (Recommended). This option is ignored in seo_magic_link (it always delete them)
- diacritics (enabled/disabled) : Replace the diacritics from text to regular ASCII letters.
Also any of these options can be dinamically modified.
Examples
Basic example :
require ('bmagicseo.class.php');
$bseo = new BMagicSeo();
$my_setings = array(
'trim' => false, //disable the trim
//a small set of Romanian prepositions and usual small words
'prop' => array('de la','cu','fara','in', 'intru','la','pe', 'de', 'pe la', 'de pe la', 'sub', 'sau','ori', 'orice', 'oricum', 'si', 'peste', 'printre', 'prin', 'dupa', 'din','de la', 'pana la', 'dintre', 'pentru')
);
$bseo->set_options($my_setings);//send your options.
$bseo->seo_magic_link('<h1>My &New #25 inches product!',20);//result : my-new-25-inches-product
$bseo->seo_magic_link('<h1>My &New #25 inches product!',20,45,false,'--');//result : my_new_25_inches_product--45
A more complex example, with a description filled with HTML tags and UTF-8 special characters you can find in the class package.
Note all the functions returns strings, array types result, or "false"(bool, use === operator) if something is wrong.
You will find more examples and documentation in the class archive (example.php and readme.html) !!
Download current version
Download the latest tested version from google project page.
Change log
Soon
Bugs and requests
Please post a comment here on the google project page if
- You like this class !
- You use (used or will use) this class
- Found a bug
- Want a feature request
- Just want to give a suggestion (how to improve my code)
Thanks !
Tags :
php,class,seo,keywords,description,meta tags,friendly,safe,web,diacritics,utf8
By .(JavaScript must be enabled to view this email address) • Tagged #Free Software #Open source PHP classes • Written September 02 2011 • So far it has 443 views and 11 Comments • Permalink •
Hi, what are your hobbies?
<a >finasteride</a> <a >levitra 10 mg</a>
Posted by EnveneNok 01/20 10:07 PM
Hello! eeckecb interesting eeckecb site! I’m really like it! Very, very eeckecb good!
Posted by Pharmk992 01/28 09:49 PM
rfjdlha uic ciluba mlink zydm xmd gratis_saker kywtdna xtz vvvkkr ggaln hiag bom
http://tylersmiths.multiply.com/journal/item/4/Paid_out_Research_As_a_method_to_produce_Speedy_Funds_On_the_web e
Posted by gratis_saker 02/15 09:10 AM
Hello! keddeed interesting keddeed site! I’m really like it! Very, very keddeed good!
Posted by Pharmd687 02/22 08:20 PM

Hello! Where better to fly to rest in March?
<a >buy zithromax</a>
Posted by amoxicillin 01/16 03:30 AM