Strange thing With CTYPE_ALNUM
html, php
Solution
`ctype_alnum` is locale-dependend. That means if you're using the standard `C` locale or a common one like `en_US`, that won't match accented letters, only `[A-Za-z]`. You can try setting the locale to a language that recognizes those derivations via `setlocale` (beware that the locale needs to be installed on your system, and not all systems are alike), or use a more portable solution like:
function ctype_alnum_portable($text) {
return (preg_match('~^[0-9a-z]*$~iu', $text) > 0);
}
Problem
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP: ``` $words="àòè"; if(ctype_alnum($words)){ Echo "Don't work"; }else{ Echo "Work"; } ``` this will echo out 'Work' BUT if i have a form and in that form i insert the letters with the grave like (à , è, ò) this will echo out 'Don't Work' Code: ``` <form action="" method="post"> <input type="text" name="words" /> <input type="submit" /> </form> $words=$_POST['words']; if(isset($words)){ if(ctype_alnum($words)){ Echo "Don't Work"; }else{ Echo "Work"; } } ``` If i insert into the text input the letters à or è or ò This will echo out 'Don't Work'