Posted by Perttu Pulkkinen on 06/02/05 15:13
"Angelos" <angelos@redcatmedia.net> kirjoitti viestissδ
news:d7mmmg$ben$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
> hello there...
> I would like to ask if there is any way of using variables which are
outside
> functions in the functions without passing them when I call the
function...
> Complicated eehh ?
> ANd the question is : DO I have to pass all the variables that I use in
the
> function when I call it ?
> I don't want to set the variables inside the functions because they are
used
> by other functions as well
1) and you remember that GET is already superglobal, so no problem with that
2) MUCH better than "globalizing" individual vars from here and there is to
make one $CFG-variable or object that is collection of those vars that are
allowed to globalize from coder's point of view
3) of course i understand and appreciate those who say: don't use any global
in fuctions. But wise $CFG doesnt't create problems.
class o() {};
$CFG=new o();
$CFG->body ="DFSDFGSDF";
$CFG->head ="aertaertaer";
function some()
{
global $CFG;
$CFG->body = "<html>....</html>";
}
[Back to original message]
|