array indexes

If you've downloaded the FAF sourcecode, and have question, please leave them here.
Post Reply
Turock
Forum Maniac
Posts: 289
Joined: Sat Jan 07, 2006 12:45 am
Contact:

Post by Turock »

Literal array indexes should be defined as $config['snafu'] instead of $config[snafu]. $config[snafu] will generate an undefined constant warning and could clash with constants that are already defined if they happened to be the same. I know that this isn't a big deal, maybe just a matter of consistency in the code. :P
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

[edit] Misunderstood the direction of the suggested change
:wq
Turock
Forum Maniac
Posts: 289
Joined: Sat Jan 07, 2006 12:45 am
Contact:

Post by Turock »

If you edit your php.ini and set error_reporting = E_ALL & E_NOTICE you'll see what I mean.
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Just so, it creates warnings if you /don't/ quote them.
:wq
Turock
Forum Maniac
Posts: 289
Joined: Sat Jan 07, 2006 12:45 am
Contact:

Post by Turock »

Right. After setting the error reporting to E_ALL & E_NOTICE, one of the notices I saw was:

undefined constant troop - assumed 'troop' in f:\apache\htdocs\prom2\conf-proc.php on line 55

Line 55 of conf-proc.php:
foreach($config[troop] as $num => $mktcost) {

Should read:
foreach($config['troop'] as $num => $mktcost) {

Like I said, not the biggest deal in the world, but if you have hundreds of instances and large userbase, then the additional overhead for php could become an issue I suppose.
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Oh, I see what you mean. Nah, it's barely any overhead for PHP. One way it has to declare the constant, the other way it declares it implicitly, makes one if-statement to see if it should print a warning, and silently declares it. No overhead. Of course, I haven't looked at the code and am only assuming.

The reason, btw, is that Promisance was written with horrible coding style and we're still kind of burdened down by that. In our own code we mostly do use quotes.
:wq
Post Reply
  • Members connected in real time

    🔒 Close the panel of connected members