php verify email is correct

藏色散人
Release: 2023-02-25 11:22:01
Original
3284 people have browsed it

php verify email is correct

# Is the php verification email correct?

1: Verify the email address by bringing it in

eg: $result = filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);

When printing the results , if the format is correct, the email address is output, if it is wrong, false

2 is output: Regular matching

(1) $regex= '/\w ([- .]\w )*@ \w ([-.]\w )*\.\w ([-.]\w )*/';

(2)$regex="/([a-z0-9]* [-_.]?[a-z0-9] )*@([a-z0-9]*[-_]?[a-z0-9] ) [.][a-z]{2,3}( [.][a-z]{2})?/i";

Both of the above two regular expressions can be used to match email addresses. The matching method is as follows:

$str = "email@example.com"; $result = preg_match($regex,$str);
Copy after login

If the email address is in the correct format, The result value is 1, and the error is false

PS: Paste the regular verification of landline and mobile phone numbers↓

$isTel="/^([0-9]{3,4}-)?[0-9]{7,8}$/"; $isMob="/^1[3-8]{1}[0-9]{9}$/";
Copy after login

For more PHP related knowledge, please visitPHP tutorial!

The above is the detailed content of php verify email is correct. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!