English 中文(简体)
把PHP改为Pspell
原标题:Getting PHP s Pspell to return corrected word as a variable

我有这一文字:

<?php
ob_start();
$get = $_GET[ q ];
$pspell = pspell_new( en , canadian ,  , utf-8 ,PSPELL_FAST);

function spellCheckWord($word) {
    global $pspell;
    $autocorrect = TRUE;
    $word = $word[0];  
    if (preg_match( /^[A-Z]*$/ ,$word)) return $word;
    if (pspell_check($pspell,$word)) return $word;
    if ($autocorrect && $suggestions = pspell_suggest($pspell,$word))
    return  <u> .current($suggestions). </u> ;
    return  <b> .$word. </b> ;
};

function spellCheck($string) {
    return preg_replace_callback( /w+/ , spellCheckWord ,$string);
};

$var = ob_get_clean();
echo $get."<br>";
echo $var;
?>

我希望,经更正的插图将变成我职能的一个变数。

最佳回答

You ve got a full mis of PHP syntax. 从一项功能中恢复的景象是NOT输出的。 您的任何职能都没有取得任何实际产出(学校、印刷等),因此产出缓冲无从捕获。 同样,这一文字中没有任何规定需要进行缓冲,这样就只能制定一些无用的法典。

你的笔试职能也正在履行。 因此,从本质上讲,这整篇文字都无动于衷,只是重复了“GET”参数。

<?php

$get = $_GET[ q ];

function spellCheckWord($word) {
    $pspell = pspell_new( en , canadian ,  , utf-8 ,PSPELL_FAST);
    ...
}

function spellCheck($string) {
    return preg_replace_callback( /w+/ , spellCheckWord ,$string);
}
echo $get, "<br>";
echo spellCheck($word);
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签