Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
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?
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.
3 Answers
- Anonymous5 years agoFavorite 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
- cpciiLv 75 years ago
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?
- MathewLv 45 years ago
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.