I am trying to run the PHP spell checker application, however, when I try to use the Enchant extension, I cannot get it to check the word for spelling errors.
Web server configuration
- PHP Version 5.4.7
- Windows Server 2008
- IIS 7
In the php.ini file, I turned on the Enchant extension. eg:
extension=php_enchant.dll
Code example :
$broker = enchant_broker_init(); $tag = 'en_US'; $bprovides = enchant_broker_describe($broker); echo "Current broker provides the following backend(s):\n"; print_r($bprovides); $dicts = enchant_broker_list_dicts($broker); echo "Current broker provides the following dictionaries:\n"; print_r($dicts); enchant_broker_set_dict_path($broker, ENCHANT_MYSPELL, 'C:\php5.4.7\lib\enchant\MySpell'); if (enchant_broker_dict_exists($broker, $tag)) { $dict = enchant_broker_request_dict($broker, $tag); $word = 'soong'; $isCorrectlySpelled = enchant_dict_check($dict, $word); if ($isCorrectlySpelled !== true) { $suggestions = enchant_dict_suggest($dict, $word); echo nl2br(print_r($suggestions, true)); } else { echo 'The word is correctly spelt!'; } } enchant_broker_free($broker);
Returns
Current broker provides the following backend(s): Array ( [0] => Array ( [name] => ispell [desc] => Ispell Provider [file] => C:\php5.4.7\libenchant_ispell.dll ) [1] => Array ( [name] => myspell [desc] => Myspell Provider [file] => C:\php5.4.7\libenchant_myspell.dll ) ) Current broker provides the following dictionaries:
However, this does not tell me whether the word "soong" is spelled correctly or not!
source share