Welcome to Geeklog Tuesday, May 21 2013 @ 03:36 PM EDT
|
||||||||
![]() |
Forum Index > Support > General Geeklog Support |
New Topic
|
Post Reply
|
Static page and global variables |
|||
| cmm |
|
||||||
![]() ![]() ![]() ![]() ![]() Newbie ![]() Status: offline ![]() Registered: 08/11/09 Posts: 1 |
I am having a problem with global variables in a static page. I have a static page set up to run php, and the only code is "include (myfile.php);"
myfile.php looks something like PHP Formatted Code <?php function1() { global $tvar; global $urlvariable; echo $tvar; echo $urlvariable; } $tvar ="1234"; $urlvariable = $_GET['urlvariable']; function1(); ?> inside function1, echo $tvar is null, and echo $urlvariable is correct The fun part is if I load the script outside of static pages, tvar works. But inside static pages the scope seems to change. My first though to fix this is to call tvar as a argument to function1, but I'd rather not have to, as I'd like to know what's causing this. Thanks for any help. |
||||||
|
|||||||
| Dirk |
|
||||||
![]() ![]() ![]() ![]() ![]() Admin ![]() Status: offline ![]() Registered: 01/12/02 Posts: 13027 |
The PHP code in a static page is itself run in the context of a function. So "global" may not be as global as you think ...
bye, Dirk |
||||||
|
|||||||
| Content generated in: 1.18 seconds |
|
|
|