imho
I agree always declare all kinds of variables before using

in the specific situation you have to consider that you are using two
different variables

rthe $foo inside the function and the $foo outside  the function I think
its' correct to declar both, imho you should use different names

if you want to check all variables are properly declared you can turn on
error reporting for all during development and wwitch it off again in
production







2005/12/14, Michael Hulse <[EMAIL PROTECTED]>:
>
> 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?
>
> I usually/always declare my arrays first, but sometimes I get a bit
> confused... for example:
>
> function give_foo() {
>        $the_foo = array(); // Declare first, good practice.
>        $the_foo = array('one', 'two', 'three');
>        // Do some stuff here...
>        return $the_foo;
> }
> $foo = give_foo(); // Declare $foo also?
>
> So, should I declare $foo as array and then give it the value of the
> function? Example:
>
> $foo = array(); // Declare first, good practice.
> $foo = give_foo();
>
> That seems kinda redundant. Thoughts?
>
> Sorry if this is a stupid question... I am self-taught, and I am trying
> to shake all my bad coding habits.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to