I am trying to combine 3-4 functions inside one function and call this inside another function. for example
public function user($user)
{ if($user==''){ $this->logerror('not valid'); //this stores error in the db
return false; }
}
I have one more for email like this
public function email($email)
{ if($email==''){ $this->loger开发者_Go百科ror('not valid'); //this stores error in the db
return false; }
}
So now I want to write a function called "validate" and then put the above two functions. then I will call this "validate" in other places when I want to validate user and email. I am not understanding how the arguments will be for the "validate" function when I want to use it. Please let me know if I am not clear.
Is this what you want ?
public function validate($user, $email)
{ if($user=='' and $email != ''){ $this->logerror('not valid'); //this stores error in the db
return false; }
}
Is this what you're trying to do ?
<?php
public function checkData($data)
{
if($data == '') {
$this->logerror('not valid'); //this stores error in the db
return false;
}
}
checkData($email);
checkData($user);
?>
public function user($user){
if($user==''){
$this->logerror('name not valid'); //this stores error in the db
return false;
}else{
return true;
}
public function email($email){
if($email==''){
$this->logerror('email not valid'); //this stores error in the db
return false;
}else{
return true;
}
}
public function validate($name, $email){
if(name($name) && email($email){
// Then the form is valid
}else{
// the form is not valid
}
}
The function validate will validate both the name and the email parameter passed
精彩评论