Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 09:31 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.
10
8
Quote
All times are EST. The time is now 09:31 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