Friday, July 28, 2006

Welcome to the PHP 5 in Practice Blog!

This is Elliott White III (though I go by Eli). One of the co-authors of the book.

I will post additional information, errata and more about the book as it becomes available.

2 Comments:

Blogger Alan Dunsmuir said...

I am currently working thru' PHP5IP, and am having a problem with code block 1.8.1 (the Spell Checker).

I have PHP5/MySQL/Apache installed on both my (Windows) Desktop and Laptop machines, and both are behaving identically.

When I load and run the spell checker I get the following (first of many) error message:

Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en_GB". in C:\Program Files\Apache Group\Apache\htdocs\bookcode.php on line 6

(I get the same error if I stick with your original "en" dictionary.)

However, I have my own little program which uses PSpell as follows:

[PHP starts here]
$word = "Center";
$dict = "en_GB";
$pspell_link = pspell_new($dict);

if (pspell_check($pspell_link, $word)) {
echo $word." is a valid word";
} else {
echo "Sorry. ".$word." is not valid[line break tag here]";
echo "Possible alternatives are:[line break tag here]";
$suggestions = pspell_suggest($pspell_link, $word);
foreach ($suggestions as $suggestion) {
echo $suggestion."[line break tag here]";
}
}
[PHP ends here]

and this works perfectly.

What is the significant difference between my code and yours which causes one to work and the other not?

Many thanks for any pointer you can provide.

5:51 AM  
Blogger Alan Dunsmuir said...

Further to my previous note, it seems (and I have posted a warning on the PHP Web Site about this) that currently PSpell only works on Windows machines if its calls are in the "main" body of PHP coding.

If they are in functions (as in your example 1.8.1) an error is thrown.

8:01 AM  

Post a Comment

<< Home