I love empty, because its fast and compact.
checking an array for a boolean value when a key does not exist, like here:
A:
if ( empty($foo['x']) ) echo 'no x';
this does not throw a notice that 'x' does not exist and is the fastest
variant compared to these two, even if 'x' exists. I especiall
Never use empty()
I've been burned by this too many times.
It's behaviour around '0' and friends changed over the years.
Some colleagues at a former job looked at me funny when they first
heard my rant about this. Then they tracked down 3 separate bugs and
fixed them, all deriving from the use
Etienne Kneuss wrote:
Hello,
On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen
wrote:
Hi,
I came across this:
echo sizeof(array());
echo sizeof("");
$a = "";
php.net/count:
"If var is not an array or an object with implemented Countable
interface, 1 will be returned. There is one excep
var_dump((array)"");
Results in:
array(1) {
[0]=>
string(0) ""
}
And 'array("")' is not empty.
-- Jille
Op 13-1-2010 14:50, Etienne Kneuss schreef:
Hello,
On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen
wrote:
Hi,
I came across this:
echo sizeof(array());
echo sizeof("");
$a =
Hello,
On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen
wrote:
> Hi,
>
> I came across this:
>
> echo sizeof(array());
> echo sizeof("");
> $a = "";
php.net/count:
"If var is not an array or an object with implemented Countable
interface, 1 will be returned. There is one exception, if var is NULL,