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 }