1

Spelling check using php, but output shows nothing, empty screen appears... How to fix it? Please help me.

    <?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");
    ?>
George Kagan
  • 5,913
  • 8
  • 46
  • 50
  • 1
    do you have library of this `pspell_config_create()`? – Alive to die - Anant Nov 27 '16 at 16:58
  • looks like `$replacement_suggest` is `false`, right? – Jeff Nov 27 '16 at 16:58
  • sorry cannot understand @ Mr. Anant –  Nov 27 '16 at 16:59
  • please replacement my code –  Nov 27 '16 at 17:00
  • 1
    Please be sure to use `error_reporting(E_ALL)` –  Nov 27 '16 at 17:00
  • i replacement $replacement_suggest true, but cannot suggest show "This is amazingly asewome", what can do –  Nov 27 '16 at 17:03
  • how to fix@Mr.jeff –  Nov 27 '16 at 17:03
  • 1
    Are you sure you have the [pspell extension](http://php.net/manual/en/pspell.installation.php) installed? A blank screen generally means you're getting an error but not viewing it, so in that case some good [error reporting](http://stackoverflow.com/q/845021/4233593) would probably help. – Jeff Puckett Nov 27 '16 at 17:06
  • If `$replacement_suggest` is `false` then you are returning `null` So nothing will be shown. Now why your dictionary does not have any suggestion, you have to debug your code to see if it's throwing any exception in your function or not. – EhsanT Nov 27 '16 at 17:21

0 Answers0