PHP.mk документација

pspell_check

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.pspell-check.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.pspell-check.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
pspell_check

Референца за `function.pspell-check.php` со подобрена типографија и навигација.

function.pspell-check.php

pspell_check

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

pspell_checkПровери збор

= NULL

pspell_check(PSpell\Dictionary $dictionary, string $word): bool

pspell_check() ја проверува правописот на зборот.

Параметри

dictionary

Еден PSpell\Dictionary instance.

word

Тестираниот збор.

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true ако правописот е точен, false ако не.

Дневник на промени

Верзија = NULL
8.1.0 На dictionary параметарот очекува PSpell\Dictionary инстанца сега; претходно, а resource се очекуваше.

Примери

Пример #1 pspell_check() Пример

<?php
$pspell
= pspell_new("en");

if (
pspell_check($pspell, "testt")) {
echo
"This is a valid spelling";
} else {
echo
"Sorry, wrong spelling";
}
?>

Белешки од корисници 3 белешки

si на youbeenx точка com
21 години пред
I felt that it would help to expand on batch spell checking using this function. The previously posted example implodes using spaces as the separator for each word. There are however situations in which doing this will not return the desired result. For example, "Hello, I like coding." will return an array with two problems, "Hello," and "coding.", both these words are spelt correctly, but pspell_check() will deem them as spelled incorrectly because a comma or a period is being passed in to the function along with the word. The following example allows you to extract only the words (using regular expressions to ignore grammar such as periods or commas) in to an array and then add in html font tags to highlight all words spelled incorrectly red before returning the string.

<?

Function SpellCheck($string) {

    $pspell_link = pspell_new("en");
    preg_match_all("/[A-Z\']{1,16}/i", $string, $words);

    for ($i = 0; $i < count($words[0]); $i++) {

        if (!pspell_check($pspell_link, $words[0][$i])) {

            $string = str_replace($words[0][$i], "<font color=\"#FF0000\">" . $words[0][$i] . "</font>", $string);        

        } 

    }

    return $string;

}

?>
digit6 на gmail точка com
пред 8 години
A better pattern for splitting the words of a query up is:

preg_match_all('/[^\w\']/+/', $query, $word)
// $words has the words.
Jcart
20 години пред
<?php

//should be using explode instead of implode
//$word = implode(" ", $message);
$word = explode(" ", $message);
foreach($word as $k => $v) {
   if (pspell_check($pspell_link, $v)) {
      echo "spelled right";
   } else {
      echo "Sorry, wrong spelling";
   };
};

?>
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.