Page 1 of 1

Constant v Array

Posted: Thu Jul 10, 2008 5:29 pm
by steakpie
Hi folks,

For a little project I am working on, I am making a language file. I have got about a quater of the way through taking any text from my script and into this file and have been doing using constants.

Before I go any further, does anyone know what will be quicker / efficient, a loads of constants, or a large lannguage array?

To me, they would just be about the same as they will both need about as many lines, however I am inexperienced and would appreciate the opinion of others more expereinced.

Cheers folks :)

Re: Constant v Array

Posted: Fri Jul 11, 2008 9:56 am
by pickle
I'd suggest using a global array. That's what is done most often in multi-language apps/sites.

Re: Constant v Array

Posted: Fri Jul 11, 2008 10:12 am
by s.dot
Right. You'll need it in a global array because you may need it in different scopes. Constants are available in all scopes, but in my opinion arrays are easier to work with. Also, I remember reading somewhere that constants are slow... but I don't remember where so I can't back that statement up.

Re: Constant v Array

Posted: Fri Jul 11, 2008 6:05 pm
by Benjamin
I've ran tests before on constants vs arrays and there was a difference but nothing significant.

I think a unique solution would be to have keys for each word that would be parsed out and replaced depending on the language before the html is sent to the browser. With this method keys could be anywhere, in the html or database, and would automagically get rendered.

Re: Constant v Array

Posted: Sat Jul 12, 2008 7:37 am
by steakpie
Actions, how do you mean keys?

Like ~~MESSAGE~~ ?

Re: Constant v Array

Posted: Sun Jul 13, 2008 2:15 pm
by Benjamin
Yeah, like {$WELCOME_MESSAGE}