note 79784 deleted from function.empty by didou

From: Date: Sun, 18 May 2008 00:53:16 +0000
Subject: note 79784 deleted from function.empty by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139471@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- According to the PHP bug repository the following behavior of empty isn't a bug, it's "a feature." If you use the __get function with an object and then test a property of that object with empty() you will ALWAYS get false. You don't even get the benefit of an error or warning like you do when you try something like empty(someFunction()); So instead you find yourself with the wonderful fun of tracing program flow. Beware using empty with objects. Better yet, use this one line wrapper function function isEmpty($value) { return empty($value) } This dodges the stupidity of the current implementation of empty() entirely. If you try to evaluate a property of an object set by __get in any way it will work with this wrapper function.

« previous php.notes (#139471) next »