PHP FILTER VALIDATE EMAIL does not work correctly

0 votes

I employ PHP 5.3.10. Here is the code:

<?php
$email = "test@example.c";
if (filter_var($email, FILTER_VALIDATE_EMAIL))
        echo "Email: ".$email." correct";
else
        echo "email not correct";
?>

"Email: test@example.c correct," it responds.

According to this list: https://data.iana.org/TLD/tlds-alpha-by-domain.txt , I'm not aware of any top level domains (TLDs) that are only one character in length.

Therefore, is the FILTER VALIDATE EMAIL filter functioning properly or not?

Aug 4, 2022 in PHP by Kithuzzz
• 38,000 points
1,063 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

It can be difficult to verify email addresses. Look at the following list:

Valid email addresses

  1. niceandsimple@example.com
  2. very.common@example.com
  3. a.little.lengthy.but.fine@dept.example.com
  4. disposable.style.email.with+symbol@example.com
  5. user@[IPv6:2001:db8:1ff::a0b:dbd0]
  6. "much.more unusual"@example.com
  7. "very.unusual.@.unusual.com"@example.com
  8. "very.(),:;<>[]".VERY."very@\ "very".unusual"@strange.example.com
  9. postbox@com (top-level domains are valid hostnames)
  10. admin@mailserver1 (local domain name with no TLD)
  11. !#$%&'*+-/=?^_`{}|~@example.org
  12. "()<>[]:,;@\"!#$%&'*+-/=?^_`{}| ~.a"@example.org
  13. " "@example.org (space between the quotes)
  14. üñîçøðé@example.com (Unicode characters in local part)

Invalid email addresses

  1. Abc.example.com (an @ character must separate the local and domain parts)
  2. A@b@c@example.com (only one @ is allowed outside quotation marks)
  3. a"b(c)d,e:f;gi[j\k]l@example.com (none of the special characters in this local part are allowed outside quotation marks)
  4. just"not"right@example.com (quoted strings must be dot separated, or the only element making up the local-part)
  5. this is"not\allowed@example.com (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash)
  6. this\ still"not\allowed@example.com (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes)

Nearly every email validation implementation is "bugged," however the php implementation is fine to use because it accepts all widely used email addresses. 

answered Aug 6, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In PHP

0 votes
0 answers

How does true/false work in PHP?

I'm curious about PHP's internal handling of ...READ MORE

Aug 4, 2022 in PHP by Kithuzzz
• 38,000 points
643 views
0 votes
0 answers

How does PHP 'foreach' actually work?

Let me start by stating that I ...READ MORE

Aug 7, 2022 in PHP by Kithuzzz
• 38,000 points
1,206 views
0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,840 points
6,003 views
0 votes
1 answer

What does double question mark (??) operator mean in PHP?

Hello, It's the "null coalescing operator", added in ...READ MORE

answered Apr 2, 2020 in PHP by Niroj
• 82,840 points
7,807 views
0 votes
1 answer

Why does the PHP json_encode function convert UTF-8 strings to hexadecimal entities?

Hii @kartik, Working with different servers with various ...READ MORE

answered Apr 20, 2020 in PHP by Niroj
• 82,840 points
7,416 views
0 votes
1 answer

Error:WP_Query() does not return all entries

Hello, Try adding posts_per_page=-1 to the string of parameters passed ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,840 points
1,269 views
0 votes
0 answers

How to validate an Email in PHP?

How can I validate the input value ...READ MORE

Jun 16, 2022 in PHP by narikkadan
• 63,600 points
501 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,848 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
11,639 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,670 points
4,838 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP