note 21524 added to function.session-register

From: Date: Thu, 16 May 2002 00:42:41 +0000
Subject: note 21524 added to function.session-register
Groups: php.notes 
Request: Send a blank email to php-notes+get-30695@lists.php.net to get a copy of this message
As of PHP 4.2.0 a variable must be global not only for registering them inside a function but for session_start() to set them inside a function too. Example: // Somewhere. session_register("aVariable"); // Another php file latter on. function foo() { session_start(); if(!isset($aVariable)) { echo("Unset"); } Will return Unset... you need to global it: // Another php file latter on. function foo() { global $aVariable; session_start(); if(!isset($aVariable)) { echo("Unset"); } Will not return (print) anything so the variable is correctly set. -- http://www.php.net/manual/en/function.session-register.php http://master.php.net/manage/user-notes.php?action=edit+21524 http://master.php.net/manage/user-notes.php?action=delete+21524 http://master.php.net/manage/user-notes.php?action=reject+21524

« previous php.notes (#30695) next »