> I got back quite a few responses on this list on the subject of having
> variables that are not defined before they are used.  That's
> interesting -- it's nice to know that I can take shortcuts and conjure
> them up on the fly, but I didn't realize that it was good practice to
> declare the variable before you actually use it in a script.  (I never
> studied programming in any formal sense, as anyone who has seen my
> source code can attest :).

You don't need to declare variables, simply initialize them before using
them in a way that wouldn't auto-initialize.

For example:

   $foo = $i++;

In this case $foo is auto-initialized, but you are incrementing $i without
explicitly initializing it to 0.  This code should be:

   $i = 0;
   $foo = $i++;

It is common sense really.


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

Reply via email to