global $HTTP_SESSION_VARS not global ???
| From: | Thomas Watson | Date: | Mon, 10 Sep 2001 15:56:18 +0000 |
| Subject: | global $HTTP_SESSION_VARS not global ??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-66768@lists.php.net to get a copy of this message | ||
Hi all,
After a bit of testing, I've noticed, that the $HTTP_SESSION_VARS array
isn't as global as the manual makes it. The following piece of code should
produce 2 blank lines and a "click here" link the first time it's loaded.
When you click on the link, I would expect two lines saying "something", but
only the second one works.
-----------------------------------------------------------
<?php
session_start();
session_register("test");
$test = "something";
function foo() {
print($HTTP_SESSION_VARS["test"] . "<br />\n");
}
foo();
print($HTTP_SESSION_VARS["test"] . "<br />\n");
?>
<a href="<?=$PHP_SELF?>">Click here</a>
-----------------------------------------------------------
I would expect the array $HTTP_SESSION_VARS to be global, and thereby
available inside the foo() function.
Have I misunderstood something in the manual?
If you think of replying that I should use the "global" declaration please
give a good argument why. I know it solves my problem, but it is still not
right according to the manual ;)
/watson