On 2001 September? 10 ,Monday 18:56, Thomas Watson wrote:
> <?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?
Yes, indeed. Global variables are not available inside functions,
unless declared with the global keyword. This is a peculiarity of PHP
(most other C-originating languages do it the other way - this is not
a statement of criticism, just a fact). The only exception to this
rule is the $GLOBALS array.
Herouth
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]