使用php检查拼写但输出空屏幕apear?

时间:2016-11-27 16:55:00

标签: php

使用php进行拼写检查,但输出显示什么,出现空白屏幕......如何解决?请帮帮我。

    <?php
    function spellSuggest($string)
    {
    $config_dic = pspell_config_create('en');
    pspell_config_ignore($config_dic, 3);
    pspell_config_mode($config_dic, PSPELL_FAST);
    $dictionary = pspell_new_config($config_dic);
    $replacement_suggest = false;
    $string = explode(' ', trim(str_replace(',', ' ', $string)));
    foreach ($string as $key => $value) {
        if(!pspell_check($dictionary, $value)) {
            $suggestion = pspell_suggest($dictionary, $value); 
           if(isset($suggestion [0]) && (strtolower($suggestion [0]) != strtolower($value))) {
                $string [$key] = $suggestion [0];
                $replacement_suggest = true;
            }
        }
    }
    if ($replacement_suggest) {
    return implode(' ', $string);
    } else {
        return null;
    }
    }
    echo spellSuggest("This is amazingly asewome");
    ?>

0 个答案:

没有答案