PHP: Email Validation

Hello friends,

Just before few days, while working with a form, we required to validate email address.

To satisfy our requirement, we have searched the web and find a “filter_var()” function.

And to validate email address using “filter_var()” function, we have passed two arguments in it.

Where first argument is an email address and second is a type of filter.

For Example:

filter_var('abc@def.ghi', FILTER_VALIDATE_EMAIL);

The above code returns email address on success and returns false if the given email address is not proper.

Hope this will help you.

Speak Your Mind

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: