Welcome to Geeklog, Anonymous Tuesday, November 10 2026 @ 07:21 pm EST
Geeklog Forums
Static page and global variables
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
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.
myfile.php looks something like
Text 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.
29
25
Quote
All times are EST. The time is now 07:21 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content