why is this coming up
Compile Error: W:\htdocs\classes\classV2.php line 9 - Declaration of EmailVlaidator::vlaidate() must be compatible with that of vlaidator::vlaidate()
<?php
interface vlaidator
{
public function vlaidate();
public function getErrors();
}
class EmailVlaidator implements vlaidator
{
private $_error;
public function vlaidate($email)
{
$trimed_email = trim($email);
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,8})$", $trimed_email))
{
$this->_error = 'Email Is not formated Correctly';
return false;
}
}
public function getError()
{
return $this->_error;
}
}
$new = new EmailVlaidator();
$new->vlaidate('vbabiy862gmail.com');
print_r($new->getErrors());
?>Change
interface vlaidator
{
public function vlaidate();
public function getErrors();
}
To
interface vlaidator
{
public function vlaidate($string);
public function getErrors();
}
Method signatures must match.
Also, unless this class deals with Vlad the Impaler you might consider changing the spelling to validator.
You might consider adding a return TRUE at the end of the method.
And later on think about why you feel the need to store an error message. The calling routine can probably figure out that it's the email that's failing. But maybe not. Depends on your implementation.
You could also return TRUE on success and an error message on failure.
Compile Error: W:\htdocs\classes\classV2.php line 9 - Declaration of EmailVlaidator::vlaidate() must be compatible with that of vlaidator::vlaidate()
<?php
interface vlaidator
{
public function vlaidate();
public function getErrors();
}
class EmailVlaidator implements vlaidator
{
private $_error;
public function vlaidate($email)
{
$trimed_email = trim($email);
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,8})$", $trimed_email))
{
$this->_error = 'Email Is not formated Correctly';
return false;
}
}
public function getError()
{
return $this->_error;
}
}
$new = new EmailVlaidator();
$new->vlaidate('vbabiy862gmail.com');
print_r($new->getErrors());
?>Change
interface vlaidator
{
public function vlaidate();
public function getErrors();
}
To
interface vlaidator
{
public function vlaidate($string);
public function getErrors();
}
Method signatures must match.
Also, unless this class deals with Vlad the Impaler you might consider changing the spelling to validator.
You might consider adding a return TRUE at the end of the method.
And later on think about why you feel the need to store an error message. The calling routine can probably figure out that it's the email that's failing. But maybe not. Depends on your implementation.
You could also return TRUE on success and an error message on failure.