Page 1 of 1

"Object with no values or functions"

Posted: Tue Oct 24, 2006 9:48 pm
by del
I was just casually browsing the 2nd edition of "Programming PHP" from O'Reilly and in the section regarding what evaluates to false it states "An object with no values or functions". But when I test this with:

Code: Select all

class EmptyClass {}
assert(new EmptyClass() == false);
The assertion fails.

Is this an error in the book?

Posted: Tue Oct 24, 2006 10:00 pm
by volka
http://www.php.net/manual/en/language.t ... an.casting
When converting to boolean, the following values are considered FALSE:
...
an object with zero member variables (PHP 4 only)
Do you use php5?

Posted: Tue Oct 24, 2006 10:38 pm
by del
Yes I do. I guess the book (which supposedly covers PHP5) wasn't updated properly in this section or something.

Thanks.