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.
我正在制作一个全名字段,并且只希望用户能够输入数字、字母和空格。在 if 语句中如何做到这一点?
您可以采取相反的方式并检查是否有任何非法字符使用,例如:
if (preg_match("/[^a-z\\d ]/i", $input)) // illegal input
另一种解决方案,
if(preg_match('/[^\w\d ]/',$input)){ //illegal input }