fritz stelluto
development for digital media
berlin, london

Using filter_var to validate email addresses in PHPHowTo

As from version 5.2, PHP comes with built-in data filtering. Which makes validating emails and URL very, very easy.

Validating email addresses in PHP

It couldn't be easier than this, could it?

function valid_email( $str=false )	{
	if( !$str )	{
		return false;
	}
	if(filter_var($str, FILTER_VALIDATE_EMAIL))	{
		return true;
	}	else	{
		return false;
	}
}

You can do much more with the new PHP filtering functions, this is all I've got time for now.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strong>