just like we have PHP's function nl2br(); which converts all the \n's to <BR>'s. The same way you can write your own function that reads the entire script, and uses pattern matching to replace the very commonly miss spelled word like:
teh, travle, tahnks.. etc ..
and then you can use:
$correct_text = spellchecker($text);
echo "$correct_text";
but, i guess this list can grow really long, for having your own words. But, you can create an external file with all the words in, and the function reads the words from the file!
how about that?