In this question here , I explained that I was afraid to save my settings in the $GLOBALS
variable because it transforms my settings into global values, so the guy answered me that he had no problem, and then asked me for the comments if they were global like . As the staff told me not to edit the question when it already has answers I created this to explain how I record the values and how I get them, and then maybe someone here can answer me if I should avoid using it or not. I also do not know if the question is the same as the one I did yesterday, but I hope not.
At this point I'm defining my variable like this:
$GLOBALS['configuracao'] = array(
'banco'=>array(
'nome'=>'proj3439',
'tabela'=>'usuarios'
),
'sessao'=>array(
'tempo'=>24,
'nomeSessao'=>'testeS'
)
);
Then if you try to print the value of it on the screen, it shows me the name and values of all global variables type SERVER_ADDR
, POST
and others.
Now, your I put the name of my configuration with the variable symbol and try to print the value of it on the screen, it returns me the values I defined before.
$GLOBALS['_CONFIG'] = array(
'banco'=>array(
'nome'=>'proj3439',
'tabela'=>'usuarios'
),
'sessao'=>array(
'tempo'=>24,
'nomeSessao'=>'testeS'
)
);
If I try to read the value of this configuration there in the same way I do with POST
, it will show me the values I put in the variable:
print_r($_CONFIG);
Then I realized that if I create a variable and put a value in it, it goes right through the variable $GLOBALS
.
$configuracao = "proj3439";
These settings I put up there only appear when I start the script that defines them, I always call this script so I have my settings always loaded. When they are started I can use them anywhere in my script , even within classes and functions, it looks like a normal variable, but I just set it straight on $GLOBALS
. >
Is there any problem setting my settings the moment I script or even in that variable?
People are able to forge data arriving by $_GET
which is also a global, and I have created a similar global. Will I have security issues?