for instance, I wanted to print $foo on page 2, or page 4, but it is showing up as not there at all when I echo it.
test.php:
Code: Select all
<?php
function test() {
$foo = "local variable";
echo '$foo in global scope: ' . $GLOBALS["foo"] . "<br>\r\n";
echo '$foo in current scope: ' . $foo . "<br>\r\n";
}
$foo = "Example content";
test();
?>
<form name="test" id="test" action="./vartest.php" method="POST">
<input type="submit" value="Submit">
</form>Code: Select all
<?php
echo '$foo in global scope: ' . $GLOBALS["foo"] . "<br>\r\n";
echo '$foo in current scope: ' . $foo . "<br>\r\n";
?>The variables do NOT have to be in a function either.
Infact, I'd prefer if they weren't.
Thanks!
ShadowIce~