Jump to content

FILTER_VALIDATE_EMAIL not working


kn0wl3dg3

Recommended Posts

That's it. That's the whole script. I was just trying to get it to work; I had tried it once before and just wrote a regex instead when I got frustrated.

 

Maybe it's in my .ini settings?

 

It is?  Even without <?php tags?  How are you calling it?

This is the entire thing:

 

<?php
echo 'Learning Email Filter<br />';


$email = "someone@exa mple.com";
echo $email; // to make sure it's being set

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "E-mail is not valid<br />";
} else {
echo "E-mail is valid<br />";
}

echo 'This will appear after the filter script if it works<br />';
?>

 

Maybe I'm not calling it correctly since you keep asking how I'm calling it. This was straight off the w3c site, so I wouldn't know if I was doing it wrong :)

What I meant was are you calling it via terminal or browser?  Hmm, I copied your script exactly and it's working for me in the CLI and browser.  You may have a fatal error, try adding these 2 lines directly under your opening <?php tag:

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Other than that there must be some environment setting that is affecting it.

What I meant was are you calling it via terminal or browser?  Hmm, I copied your script exactly and it's working for me in the CLI and browser.  You may have a fatal error, try adding these 2 lines directly under your opening <?php tag:

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Other than that there must be some environment setting that is affecting it.

 

This is what I get with errors on:

 

Fatal error: Call to undefined function filter_var() in /var/www/html/learning/email_filter.php on line 12

 

As to your other question, terminal or browser, I'm not sure what you mean, but i wrote it in a file and opened it in my browswer, so I'm assuming the answer is browser :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.