note 10435 deleted from function.session-register by jimw

From: Date: Tue, 18 Dec 2001 22:25:07 +0000
Subject: note 10435 deleted from function.session-register by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23256@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

« previous php.notes (#23256) next »