Email Validation php When validating an email address using the code below I get this error when i run the same code from within a drupal node, where I coded a form using php/html

if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) {
$errors[] = 'Please enter valid email';
}


I get this error:

Fatal error: Call to undefined function filter_var() in /var/www/html/drupal1/includes/common.inc(1743) : eval()'d code on line 53
A better option might be to use valid_email_address() to keep it all Drupal friendly :)


  Verifies the syntax of the given e-mail address.
  
  See RFC 5322 for details.


Example:

if (valid_email_address($email) != TRUE) {
  $errors[] = 'Please enter valid email';
}