Re: Declaring arrays? Good practice?

From: Date: Wed, 14 Dec 2005 04:20:28 +0000
Subject: Re: Declaring arrays? Good practice?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-227401@lists.php.net to get a copy of this message
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

« previous php.general (#227401) next »