On Jan 6, 2011 4:24 PM, "SÃndor TamÃs" <sandortamas@xxxxxxxxxxx> wrote: > > In that case you should use include_once in every script. But if you are absolutely sure that all scripts will be processed, you can include it only in one of them, because PHP - in short terms - does a file include, so it will look like as the included file is part of the script. > The global keyword does not do what you think, it only propagates variables between functions without passing them as parameters. In general, you ought to avoid using global, because it can make your script less readable, and / or can lead to logical errors. > > Because I am OOP fan, I'd rather create a static class, using public static fields, so you can reach those variable as like ConstClass::MyConstant. In that way, you have the advantage of simply create new constants, and it doesn't matter how many times you include this file, there will be only one instance. If you include the file several times, you still have the problem of redeclaring the class, so you'd have to wrap the definition in a conditional, which sucks, or use the *_once functions and incur the overhead. Much better to be in control of the includes. Apart from that, it's generally better to use require* instead of include*. If the file is needed, don't continue without it, as the consequences will be unknown. > SanTa > > 2011.01.05. 23:40 keltezÃssel, Paul Halliday Ãrta: > >> Say you have 10 or so scripts and a single config file. If you have >> main.php, functions1.php, functions2.php, functions3.php.. >> >> Does is hurt to do an include of the config file in each separate >> script, even if you only need a few things from it, or should you >> just specify what you want with a 'global' within each >> script/function? >> >> Thanks! >> >