Location: PHPKode > scripts > PHP Spell Checker > php-spell-checker/examples/hunspellBased.php
<?php

// include the class
require_once(dirname(__FILE__)."/../HunSpellChecker.class.php");

// instantiate the class
$spellCheck = new HunSpellChecker();
$spellCheck->setHunspellPath(dirname(__FILE__)."/../hunspell"); // set path for windows systems
/////////////////////////
// set some text to check
$text1 = "Die Commerzbank blickt besorgt in die Zukunft: Das Geldhaus rechnet in der zweiten Jahreshälfte mit einer Zunahme von Kreditausfällen - denn Firmen wie Privatkunden bekommen Probleme, ihre Schulden zu bedienen. Schon jetzt hat das Institut vorsichtshalber knapp eine Milliarde Euro zurückgelegt";
$result = $spellCheck->checkSpelling($text1, "de-DE"); // should return an empty array (text is correct)
//print_r($spellCheck->getWarnings());// get all warnings
//print_r($spellCheck->getErrors());// get all errors
if (count($result) == 0) {
	print "Text is OK !<br/>";
} else {
	print "Text has errors !<br/>";
	print "<pre>";
	print_r($result);
}
$spellCheck->clearWarnings(); // clear all previous warnings
$spellCheck->clearErrors(); // clear all previous errors

$text1 = "PHP: the quik browm fox jumps over the lazi dog"; // this text has 3 errors
$result = $spellCheck->checkSpelling($text1, "en-US"); // will return an array with the wrong words with associated suggestions
//$result = $spellCheck->checkSpelling($textWithErrors, "en-US", false); // will return an array with the wrong words without associated suggestions
//print_r($spellCheck->getWarnings());// get all warnings
//print_r($spellCheck->getErrors());// get all errors
if (count($result) == 0) {
	print "Text is OK !<br/>";
} else {
	print "Text has errors !<br/>";
	print "<pre>";
	print_r($result);
}

?>
Return current item: PHP Spell Checker