PHP and Javascript Email Validation of '@' Symbol

后端 未结 4 922
暗喜
暗喜 2021-01-25 01:21

Trying to get code to search if \'@\' symbol is present in typed-in email address and echo if symbol is not. Everything works fine without the searching for @ code.

chec

4条回答
  •  情书的邮戳
    2021-01-25 01:46

    A much better approach to validating the emails, would be to use the built in filters intended for that sort of thing

    
    

    The reason your code doesn't work, is because PHP doesn't have a str or indexOf method, you should be using something like strpos instead

    if (strpos($email, '@') === false) { ...
    

提交回复
热议问题