• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Initializing arrays

#4
[eluser]BrianDHall[/eluser]
[quote author="trenchard" date="1257286355"]Thanks. It makes sense to me to initialize all variable as well.[/quote]

If nothing else you never again run into those darn PHP errors that refer to referencing an uninitialized variable. It helps for lots of reasons, and it is indeed just a good practice and habit to have. PHP is one of the only languages that even lets you get away with using variables without initializing.

One thing I do not do, however, is go out of my way to initialize everything if I'm going to be using something for the first time and immediately assigning it to a variable. For instance:

Code:
$var = $foo + 2 / 1.5;

$temp_var = $var;

$var++;

In both cases I see no reason to just initialize to be initializing - so don't get too carried away Smile


Messages In This Thread
Initializing arrays - by El Forum - 11-03-2009, 10:05 AM
Initializing arrays - by El Forum - 11-03-2009, 10:07 AM
Initializing arrays - by El Forum - 11-03-2009, 10:12 AM
Initializing arrays - by El Forum - 11-03-2009, 10:48 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.