Page 1 of 1

what does this line mean?

Posted: Mon Jul 09, 2012 8:28 am
by ashiland
public function Validname()
{
return !empty($this->_nom);
}

I don't understand the meaning of return !empty($this->_nom);

thanks.

Re: what does this line mean?

Posted: Mon Jul 09, 2012 9:11 am
by karolismf
Your code:

Code: Select all

public function Validname()
{
return !empty($this->_nom);
}
!empty = not empty.
$this->_nom = (private $_nom; in class)
if you want a detailed explanation what $_nom does in your case give us your all class code. :)

Re: what does this line mean?

Posted: Mon Jul 09, 2012 9:18 am
by ashiland
Thanks, but I don't quite understand what "return !empty" means together.

Re: what does this line mean?

Posted: Mon Jul 09, 2012 10:15 am
by pickle
! means not.

So you're returning opposite of whether or not $this->_nom is empty. The idea being, if the variable is not empty, or !empty(), then the name must be valid, hence the function name "Validname"

Re: what does this line mean?

Posted: Mon Jul 09, 2012 11:39 am
by ashiland
Thanks for your help pickle; my problem was the hidden 'if' in the code, I didn't know that.
Thanks again.