2024 年 PHP Conference Japan

pspell_store_replacement

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

pspell_store_replacement儲存單字的取代配對

描述

pspell_store_replacement(PSpell\Dictionary $dictionary, 字串 $misspelled, 字串 $correct): 布林值

pspell_store_replacement() 會儲存一個單字的替換配對,以便之後 pspell_suggest() 可以返回該替換。為了利用這個函式,您必須使用 pspell_new_personal() 來開啟字典。為了永久儲存替換配對,您必須使用 pspell_config_personal()pspell_config_repl() 設定儲存自訂詞彙列表的路徑,然後使用 pspell_save_wordlist() 將變更寫入磁碟。

參數

dictionary

一個 PSpell\Dictionary 實例。

misspelled

拼錯的單字。

correct

misspelled 單字的正確拼法。

返回值

成功時返回 true,失敗時返回 false

更新日誌

版本 描述
8.1.0 dictionary 參數現在需要一個 PSpell\Dictionary 實例;先前需要的是 資源

範例

範例 #1 pspell_store_replacement()

<?php
$pspell_config
= pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell = pspell_new_config($pspell_config);

pspell_store_replacement($pspell, $misspelled, $correct);
pspell_save_wordlist($pspell);
?>

注意事項

注意:

除非您擁有 pspell .11.2 和 aspell .32.5 或更高版本,否則此函式將無法運作。

新增註記

使用者貢獻的註記

此頁面沒有使用者貢獻的註記。
To Top