Bug #15289 Updated: Global variables do not work with session.

From: Date: Wed, 30 Jan 2002 07:53:07 +0000
Subject: Bug #15289 Updated: Global variables do not work with session.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-78512@lists.php.net to get a copy of this message
ID: 15289 Updated by: derick Reported By: brubla@seznam.cz Old Status: Open Status: Bogus Bug Type: Session related Operating System: Linux PHP Version: 4.1.1 New Comment: 1. Using global in a non-function scope doesn't make any sense. 2. When doing 'global $counter' you're setting a reference from $counter to $GLOBALS['counter'] and thus breaking the reference to the session hashes Not a bug (but rather a bug in older versions). Making this bogus. Previous Comments: ------------------------------------------------------------------------ [2002-01-29 22:13:11] brubla@seznam.cz Global variable will be registered in session only first time. When you will be refreshing page with following code, it will count only to 2. <?php session_start(); global $counter; //when you remove this row, all will work properly session_register("counter"); $counter++; echo $counter; ?> When you remove row with "global $counter;" page will count to 3, 4, 5... Both variants of code works properly with PHP 4.0.6 (on Windows 2000). ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=15289&edit=1

« previous php.dev (#78512) next »