Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查文本框中的用户输入是否不包含任何特殊字符。如何在不使用任何 javascript/Jquery 的情况下验证文本框
试试这个,$name是用户输入,
$name
if(preg_match('/[^a-z0-9 _]+/i', $name)) { // preg_match will return true if it finds // a character *other than* a-z, 0-9, space and _ // *anywhere* inside the string }