PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of sam   MySQL Spell Checker   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: MySQL Spell Checker
Spell check texts with a MySQL table as dictionary
Author: By
Last change: update to comments
Date: 18 years ago
Size: 1,073 bytes


Class file image Download
include 'spell-checker-class.php'; // include the spell checker class

$spell_checker = new spell_checker; // Creat an instance of spell checker class
// set the info to use when doing things with MySQL
$spell_checker->set_mysql_info ('username', 'password', 'database_name');
$spell_checker->db_connect(); // connect to MySQL
if ($spell_checker->check_word('test')) // find out if test is in the dic
'Test is in the dic'."\n";
'You need a better dic'."\n";
$str = 'this is a string with a tiepoo.'."\n";
// get all the words from the string and store them in an array in the class
$wrong = $spell_checker->get_next_wrong_word();)
'This word from the var str is wrong:' . $wrong . "\n";
$spell_checker->replace_all($str); // replace all the wrong words in $str
echo 'the words in the array below have a soundex like the word test'."\n";
$spell_checker->close_db(); // close db link