note 10435 added to session_register
| From: | finnur at spuni dot is | Date: | Wed, 03 Jan 2001 18:37:24 +0000 |
| Subject: | note 10435 added to session_register | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9346@lists.php.net to get a copy of this message | ||
Some note about session_register() scope. I ecountered problems while trying to register varible
inside a function in one of my classes in my web application. Apparently this function can only be
properly called from the scope of the page, not from some functions on that page:
Doesn't work:
// file test.php
function smuu()
{
session_register("theVar");
$theVar = "Hello world";
smuu2();
}
function smuu2()
{
global $theVar;
echo $theVar;
}
This works:
// file test.php
// do this before output
session_register("theVar");
function smuu()
{
global $theVar;
$theVar = "Hello world";
smuu2();
}
function smuu2()
{
global $theVar;
echo $theVar;
}
Happy programming
Finnur
http://www.php.net/manual/function.session-register.php