
March 13th, 2013, 03:20 AM
|
 |
A Change of Season
|
|
|
|
|
Filter_var what are you doing?
Why does it print Not valid?
PHP Code:
<?php
class Validator
{
public function validate($string, $type)
{
if($type=='email')
{
if(!filter_var($string, FILTER_VALIDATE_EMAIL))
{
return FALSE;
}
}
}
}
$object = new Validator();
$string = 'ben@yahoo.com';
$type = 'email';
if($object->validate($string, $type))
{
echo "Valid";
}
else
{
echo "Not Valid";
}
|