PHP 4.0 Bug #6161: Global variable acts strangely

From: Date: Tue, 15 Aug 2000 09:55:52 +0000
Subject: PHP 4.0 Bug #6161: Global variable acts strangely
Groups: php.dev 
Request: Send a blank email to php-dev+get-28885@lists.php.net to get a copy of this message
From: andrew@andrew.org Operating system: GNU/Linux PHP version: 4.0.1pl2 PHP Bug Type: Session related Bug description: Global variable acts strangely I have some code whose behaviour changes unexpectedly (at least as far as I'm concerned :-). I am modifying some global var value inside a function and reading this value in some class method accessing it defining it "global", and it does different things whether I declare the variable as global or access it through the $GLOBALS array, in the modifying function. I don't know if this is not meant to be, I thought the two syntaxes had the same use, and nothing else makes me doubt about this (not even the manual). It took me hours to isolate the problem. It looks rather nasty. The suspect code involves sessions (the global var in subject is registered), that's why I marked this report as session related. It looks as if the changes don't get applied to the session if I change the variable's value when defined as global in my function, while they do get applied when I use the $GLOBALS array. But I have not been able to reproduce this (alleged) misbehaviour on purpose. Please let me know.

« previous php.dev (#28885) next »