Re: [PHP] Re: register_globals odd behaviour?

2001-08-22 Thread Sean C. McCarthy

Hi,

Internally I use variables but I use the array to update the value since
I have problems with the scope inside classes. So I update the value on
the array just at the end of the script by registering an update
function with register_shutdown_function().

What is the reason that I should not use the array? Is there any problem
doing it that way?

Thanks in advance.

Sean C. McCarthy
SCI, S.L. (www.sci-spain.com)

PS: By the way I couldn't find this bug in the bug database.

Richard Lynch wrote:
 
 I think you should still use $count++
 
 The array is just there for you to *READ* data, not to alter it.
 
 --
 WARNING [EMAIL PROTECTED] address is an endangered species -- Use
 [EMAIL PROTECTED]
 Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
 Volunteer a little time: http://chatmusic.com/volunteer.htm
 - Original Message -
 From: Sean C. McCarthy [EMAIL PROTECTED]
 Newsgroups: php.general
 To: PHP General List [EMAIL PROTECTED]
 Sent: Tuesday, August 21, 2001 1:00 AM
 Subject: register_globals odd behaviour?
 
  Hi All,
 
  I just come across and odd behaviour with the register_globals and
  session handling. The problem is that when I set the register globals to
  on I cannot access the session_variables through the associative array
  HTTP_SESSION_VARS. The manual says explicitly that with track_vars and
  register_globals both on the array and the vars will point to the same.
 
  It just doesn't happen the vars are not written at the end of the
  script. I mean with register_globals ON:
 
  ?
  session_register(count);
  $HTTP_SESSION_VARS[count]++;
  ?
 
  this does not work. My php is PHP Version 4.0.3pl1 running on Linux
  2.2.18 and Apache1.3.9 . Does this bogus behaviour happen with higher
  versions too?
 
  Thanks in advance.
 
  Sean C. McCarthy
  SCI, S.L. (www.sci-spain.com)
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: register_globals odd behaviour?

2001-08-22 Thread Richard Lynch

 What is the reason that I should not use the array? Is there any problem
 doing it that way?

They array is simply not designed for you to use as if it were your
variable.

What you want to do is this:

?php
# Beginning of script:
session_start();
session_register('count');
$count = $HTTP_SESSION_VARS['count'];
.
.
.
# In your class methods:
class ...
function ...
global $count;
}
}
.
.
.
# At the end of your script.
# Nothing.  $count is your variable, it's registered, coo coo ka choo
?

You are changing $HTTP_SESSION_VARS['count'], but I'm betting the *GLOBAL*
variable $count is not changing, and *THAT* is what was registered, and
*THAT* is what gets save.  $count in the global name-space.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]