RE: [PHP] Boolean-cast and arrays

From: Date: Thu, 08 Feb 2007 15:53:21 +0000
Subject: RE: [PHP] Boolean-cast and arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-248583@lists.php.net to get a copy of this message
sorry typo, make that: > Shouldn't have been simply doing: > > $arr = array(); > If (!$arr) {} > -----Message d'origine----- > De : Tim [mailto:user@internet46.fr] > Envoyé : jeudi 8 février 2007 16:49 > À : php-general@lists.php.net > Objet : [PHP] Boolean-cast and arrays > > First thank you all for your input on "all-in-one" classes. > > Reading the php manual on boolean types and casts, and came accros the > following: > > <quote> > When converting to boolean, the following values are considered FALSE: > > ... > > an array with zero elements > > ... > </quote> > > So here I am sitting and wondering if after all this while doing: > > $arr = array(); > If (count($arr) == 0) {} > > Shouldn't have been simply doing: > > $arr = array(); > If (!arr) {} > > > Is the latter problematic in any programming standards? > Does it take longer to process? > Is it using count()? > Is "Type-Juggling" considered good practise? > > Regards, > > Tim > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#248583) next »