Re: empty() and SplFixedArray

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 24, 2014 at 10:29 PM, Michael Rubin <mrubin@xxxxxxxxxx> wrote:

> I've been converting some code from using array to SplFixedArray and I ran
> into a gotcha - empty(array()) returns true whereas empty(new
> SplFixedArray()) returns false.
>
> Is this considered a bug?
>

Emptiness is a matter of definition when it comes to objects. I guess that
is why objects will never pass the empty() test regardless (even with a new
stdClass) in PHP. Arrays on the other hand are simpler than objects (I like
to think of them as a collection of variables) which you can easily check
if the collection is empty or not.

A fast way to check would be empty ((array) $object) - which only works on
PHP >= 5.5.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux