前一段时间,做的项目中有文件上传OSS的需求,然而被上传的文件名千奇百怪,于是写了这个检测过滤方法。
function replaceSpecialChar(
$strParam){//过滤特殊字符
$regex = "/
\/|
\~|
\!|
\@|
\#|
\\$|\%|\^|\&|\*|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\s|\.|\/|\;|\'|\`|\=|\\\|\|/";
return preg_replace($regex,"",
$strParam);
}