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’
ctype_alnumis locale-dependend. That means if you’re using the standardClocale or a common one likeen_US, that won’t match accented letters, only[A-Za-z]. You can try setting the locale to a language that recognizes those derivations viasetlocale(beware that the locale needs to be installed on your system, and not all systems are alike), or use a more portable solution like: