note 7944 modified in function.session-register by imajes
| From: | imajes@php.net | Date: | Thu, 31 Jan 2002 05:17:51 +0000 |
| Subject: | note 7944 modified in function.session-register by imajes | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-26066@lists.php.net to get a copy of this message | ||
Registering a variable creates a global instance of the variable, but it does not automatically pull
it into the local scope.
So to set a registered variable within a function:
<?
session_start();
function test( $val ) {
session_register( "somevar" );
// $somevar = $val; //-- This will NOT set the value of the registered somevar, instead it creates
a local, albeit unrelated, instance
$GLOBALS['somevar'] = $val; //This sets the registered $somevar
}
test( "A value" );
?>
--was--
Registering a variable creates a global instance of the variable, but it does not automatically pull
it into the local scope.
So to set a registered variable within a function:
<?
session_start();
function test( $val ) {
session_register( "somevar" );
// $somevar = $val; //-- This will NOT set the value of the registered somevar, instead it creates
a local, albeit unrelated, instance
$GLOBALS['somevar'] = $val; //This sets the registered $somevar
}
test( "A value" );
?>
http://www.php.net/manual/en/function.session-register.php