11
In that question here, I explained that I was afraid to save my settings in the variable $GLOBALS
because she turns my settings into global values, then the guy answered me that there was no problem, and then asked me by the comments if they were global like.
I created this example to explain how I record the values and how I catch them, and then maybe someone here can answer me if I should avoid using it or not. I also don’t know if the question is the same as the one I asked yesterday, but I hope.
Right now I’m setting my variable like this:
$GLOBALS['configuracao'] = array(
'banco'=>array(
'nome'=>'proj3439',
'tabela'=>'usuarios'
),
'sessao'=>array(
'tempo'=>24,
'nomeSessao'=>'testeS'
)
);
Ai if your try to print its value on the screen, it presents me the name and values of all type global variables SERVER_ADDR
, POST
and others.
Now, if I put the name of my configuration with the variable symbol and try to print its value on the screen, it returns me the values I set 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 setting there the same way I do with the POST
, it will show me the values I put in the variable:
print_r($_CONFIG);
Then I also realized that if I create a variable and put a value on it, it goes right into the variable $GLOBALS
.
$configuracao = "proj3439";
These settings I put up there only appear when I start the script that defines them, I always call that 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 only that I defined it directly in the $GLOBALS
.
Have any problem setting my settings the moment I run the script or even in that variable?
The people can forge data that comes through $_GET
which is also a global one, and I ended up creating a similar global one. I will have security problems?
The text is perfect, but I did not understand the purpose of the question, that is, the final sentence.
– Maniero
Sorry, I will delete this question, I saw that she is not very different from the other. I will use Google to help fill my question.
– Laura
You can leave it, I just don’t quite understand what you want to know. It doesn’t matter if it’s different, on the contrary, if it’s different, better yet.
– Maniero
Defining her in the
$GLOBALS
I can use it from anywhere, even within functions without using the wordglobal
the front.– Laura
You want to know the difference and the advantage of using one or the other?
– Maniero
The people can forge data that comes through
GET
which is also a global, and I ended up creating a similar global understands ?– Laura