PHP not recognising include variables.?

<php
include "test.php";
$GLOBAL["TEST"] = "FooBar"
?>

---------
test php
<?php
$test=$GLOBAL["TEST"];
echo $test
?>

DOES NOT WORK. Why lol?

2015-11-26T07:57:29Z

Thanks everyone.
@Kevy spot on, the global was declared after the include thus the value was not passed.
@cpcii No thats all the code there is, the index.php and test.php.
@mathew, umm thanks for taking the time to reply.

I just wanted to see how many people actually understood code, and kevy certainly does :)
Ill post another question and deliberately not pass the variable to a function, resulting in the variable never being passed.

Anonymous2015-11-25T10:09:59Z

Favorite Answer

Your include# is put before your TEST variable... so your code actually looks like this:

$test=$GLOBAL["TEST"]; ### YOU CALLED $TEST before you created $TEST
echo $test
$GLOBAL["TEST"] = "FooBar" ### you created $TEST

-----------------------------------------------------------
Just put your Include below your Global $TEST

cpcii2015-11-25T10:07:52Z

Are you calling the previous page or is this all in one page?

Where are you defining the global test variable? In your php.ini? or earlier in the page?

Mathew2015-11-26T02:17:51Z

Consult some one who is expert at this, he might help you and if you need some good security app you could get Leo Privacy Guard in order to secure all your apps with it.