downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Enchant Functions> <Predefined Constants
[edit] Last updated: Fri, 26 Apr 2013

view this page in

Examples

Example #1 Enchant Usage Example

<?php
$tag 
'en_US';
$r enchant_broker_init();
$bprovides enchant_broker_describe($r);
echo 
"Current broker provides the following backend(s):\n";
print_r($bprovides);

$dicts enchant_broker_list_dicts($r);
print_r($dicts);
if (
enchant_broker_dict_exists($r,$tag)) {
    
$d enchant_broker_request_dict($r$tag);
    
$dprovides enchant_dict_describe($d);
    echo 
"dictionary $tag provides:\n";
    
$wordcorrect enchant_dict_check($d"soong");
    
print_r($dprovides);
    if (!
$wordcorrect) {
        
$suggs enchant_dict_suggest($d"soong");
        echo 
"Suggestions for 'soong':";
        
print_r($suggs);
    }
    
enchant_broker_free_dict($d);
} else {
}
enchant_broker_free($r);
?>


Enchant Functions> <Predefined Constants
[edit] Last updated: Fri, 26 Apr 2013
 
add a note add a note User Contributed Notes Examples - [5 notes]
up
0
edward dot 81 at gmail dot com
4 months ago
If you pass a word with special chars on it (es. òàùèì) you have to convert the string to utf8 or enchant don't recognize correctly the word.

Es.
$word = "perché";
enchant_dict_check($dict, utf8_encode($key));
up
0
robert dot johnson at icap dot com
7 months ago
Here is help for Windows users:

You need to add dictionaries to your computer for Enchant.

1. Enchant looks in your registry keys, I don't know what keys it wants, but it looks here - I ignored all of these:
  * Default User\Software\Enchant\Config
  * Default User\Software\Enchant\Ispell
  * Default User\Software\Enchant\Myspell
2. It looks for OpenOffice dictionaries (from the registry settings for OpenOffice)
3. It looks in folder [PHP]\share\myspell\dicts

I got it working by copying the en-us dictionary files from Firefox into \share\myspell\dicts, and renaming them en_US.*.  You can download and install dictionaries from OpenOffice from here I think: http://extensions.services.openoffice.org/dictionary

Enchant creates and writes to the following folder, so you must allow PHP read and write permissions to: [SYSTEM32]\config\systemprofile\Application Data\enchant

It would be convenient if Enchant could accept parameters to specify the location of the main dictionaries and user-dictionaries, I suppose the registry keys are the only way to do it.
up
0
Anonymous
9 months ago
So that you don't need to track down dictionaries to use with Enchant, here are some notes for installing aspell dictionaries on your Mac using Macports.

Install Enchant (this should also install aspell as a dependency):
sudo port install php5-enchant

Find available dictionaries:
port search aspell-dict

Install the English dictionary:
sudo port install aspell-dict-en
up
0
nils dot rocine at gmail dot com
10 months ago
I installed Enchant through MacPorts (port php5-enchant.)

Testing the example: Enchant found 3 brokers: aspell, ispell, and myspell. But found no dictionaries.

I'm not sure if the providers were installed by the php5-enchant port, or from some other port I previously installed. The bins for these apps live in /opt/local--the default MacPorts install directory--so I don't think they came with my distribution (OS X.)

To run the sample code to the results described, I installed the aspell English dictionary from ftp://ftp.gnu.org/gnu/aspell/dict/0index.html  and installed with the standard pattern: tar -xzvf [download] then cd [dictionary dir] and ./configure ; make ; sudo make install
up
0
iwanluijks at gmail dot com
2 years ago
For more information on Enchant, check my latest blog-post at http://bit.ly/cGwmb7 . It describes setting up Enchant with PHP on Windows.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites