Re: Declaring arrays? Good practice?

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

 



On Tue, Dec 13, 2005 at 07:34:31PM -0800, Michael Hulse wrote:
> Sorry if this question sounds noobish:
> 
> $foo = array(); // Declare first, good practice.
> $foo = array('one', 'two', 'three');
> 
> Using above as example, is it good to always declare the array first?

Well there really isn't any "declaration" in php, it is how you
initialize the variable.  By just doing a:

  $foo = array('one', 'two', 'three');

It is an explicit intialization and we know that anytime in later
code this thing is going to be an array and returned as an array.
The need to define the var as an empty array first is just extra
unneeded work

Curt.
-- 
cat .signature: No such file or directory

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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