PHP Tip: About the spell checker library in PHP scripts

Source: Internet
Author: User
Tags array integer valid

Aspell_new: Load a new dictionary.

Aspell_check: Check a word.

Aspell_check-raw: Check a word, even if misspelled, does not change or correct.

Aspell_suggest: Check a word and provide spelling advice.

Aspell_new

Load a new dictionary.

Syntax: int aspell_new (string master, string personal);

return value: Integer

Function type: Data processing

Content description This function loads a new dictionary and assigns a new identity value (integer) for use in the program.

Use the example $aspell _link=aspell_new ("中文版");

Aspell_check

Check a word.

Syntax: boolean aspell_check (int dictionary_link, string word);

Return Value: Boolean value

Function type: Data processing

Content Description This function checks the spelling of the word. Returns true if the spelling is correct, or false if incorrect.

Usage examples

The following are the referenced contents:
$aspell _link=aspell_new ("中文版");
if (Aspell_check ($aspell _link, "Testt")) {
echo "This is a valid spelling";
} else {
echo "Sorry, wrong spelling";
}
Aspell_check-raw

Check a word, even if misspelled, does not change or correct.

Syntax: boolean aspell_check_raw (int dictionary_link, string word);

Return Value: Boolean value

Function type: Data processing

Content Description

This function checks the spelling of the word. Returns true if the spelling is correct, or false if incorrect. This function does not change or fix the user's spelling.

Usage examples

The following are the referenced contents:
$aspell _link=aspell_new ("中文版");
if (Aspell_check_raw ($aspell _link, "Testt")) {
echo "This is a valid spelling";
} else {
echo "Sorry, wrong spelling";
}
Aspell_suggest

Check a word and provide spelling suggestions.

Syntax: array aspell_suggest (int dictionary_link, string word);

return value: Array

Function type: Data processing

Content Description

This function checks the spelling of the word. and give possible spellings and correct suggestions to the array type to return the result.

Usage examples

The following are the referenced contents:

?
$aspell _link=aspell_new ("中文版");
if (!aspell_check ($aspell _link, "Testt")) {
$suggestions =aspell_suggest ($aspell _link, "Testt");
For ($i =0 $i < count ($suggestions); $i + +) {
echo "Possible spelling:". $suggestions [$i]. "<br>";
}
}
?>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.