I'm not sure how to do this one

pbismad had mentioned this in another thread

5) Your methods need to return a TRUE value when they succeed. They are currently returning a NULL value upon success, which your current code will treat the same as a FALSE value.

class Login
{	
	private 
	$email,
	$password;


public function validEmail($email)
{	
	return (filter_var($email, FILTER_VALIDATE_EMAIL) !== FALSE);  

	return $email;
}	

public function emptyPassword($password)
{
	return (empty($password) !== TRUE);

	return $email;
}


}

How do I return it as true? Recommended reading would be appreciated initally I had thought something like this...

class Login
{	
	private 
	$email,
	$password;


public function validEmail($email)
{	
	return (filter_var($email, FILTER_VALIDATE_EMAIL) !== FALSE);  

	return $email;
            return true;
}	


}

But that seems too simple to be right

    You can only have one return statement within any code execution path, because the first one that gets executed stops execution along that path, so all the above code makes no sense.

    My comment referred to code that was returning a false value upon failure, but wasn't doing anything upon success. In this case, when the code in the function/method reached the end of execution, a null value is returned to the calling code. If I remember correctly, the code testing the returned value was only doing a 'loose' comparison (an == or a != ). For these comparisons, a false and a null are the same, so, for that particular code, doing nothing for a success, which returned a null value, would look exactly the same as a false value.

    The 'fix' for that particular code would have been to explicitly return a true value upon success (a null value would not be a good choice for a success value.)

      Ah ok, I'm with you. I have some new tutorial website I'm assured is good so we'll see how it goes

        Write a Reply...