PHP技巧:PHP指令碼中關於拼字檢查函數庫

來源:互聯網
上載者:User

aspell_new :  載入一個新的字典。

aspell_check :  檢查一個單字。

aspell_check-raw :  檢查一個單字,即使拼錯也不改變或修正。

aspell_suggest :  檢查一個單字,並提供拼字建議。

aspell_new

載入一個新的字典。

文法:int aspell_new(string master, string personal);

傳回值:整數

函數種類:資料處理

內容說明 本函數載入一個新的字典,並賦與一個新的身份值 (整數),以供程式中使用。

使用範例 $aspell_link=aspell_new("english");

aspell_check

檢查一個單字。

文法:boolean aspell_check(int dictionary_link, string word);

傳回值:布爾值

函數種類:資料處理

內容說明 本函數檢查單字的拼字。若拼字正確則返回 true,不正確則返回 false。

使用範例

以下為引用的內容:
$aspell_link=aspell_new("english");
if (aspell_check($aspell_link,"testt")) {
echo "this is a valid spelling";
} else {
echo "sorry, wrong spelling";
}
aspell_check-raw

檢查一個單字,即使拼錯也不改變或修正。

文法:boolean aspell_check_raw(int dictionary_link, string word);

傳回值:布爾值

函數種類:資料處理

內容說明

本函數檢查單字的拼字。若拼字正確則返回 true,不正確則返回 false。本函數不會改變或者修正使用者的拼字。

使用範例

以下為引用的內容:
$aspell_link=aspell_new("english");
if (aspell_check_raw($aspell_link,"testt")) {
echo "this is a valid spelling";
} else {
echo "sorry, wrong spelling";
}
aspell_suggest

檢查一個單字,並提供拼字建議。

文法:array aspell_suggest(int dictionary_link, string word);

傳回值:數組

函數種類:資料處理

內容說明

本函數檢查單字的拼字。並給予可能的拼法及正確的建議,以數群組類型將結果返回。

使用範例

以下為引用的內容:

<?
$aspell_link=aspell_new("english");
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>";
}
}
?>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.