this function can be used like strspn(), except while that can be used to compare a string with an allowed pattern, this one can be use to compare a string with a FORBIDDEN pattern
so, to know if any forbidden character has a position inside our string, we can use (not tested with backslashes)...
<?php
// LARGE VERSION
$forbidden="\"\\?*:/@|<>";
if (strlen($filename) != strcspn($filename,$forbidden)) {
echo "you cant create a file with that name!";
}
// SHORT VERSION
if (strlen($filename) - strcspn($filename,"\"\\?*:/@|<>")) {
echo "i told you, you cant create that file";
}
?>