Re: Re: register_globals odd behaviour?
| From: | Sean C. McCarthy | Date: | Thu, 23 Aug 2001 15:31:32 +0000 |
| Subject: | Re: Re: register_globals odd behaviour? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64111@lists.php.net to get a copy of this message | ||
Hi,
Actually is what I do but since register global is off, I do:
# Beginning of script:
session_start();
session_register('count');
$sess_object->count = $HTTP_SESSION_VARS['count'];
.
.
.
# In your class methods:
class ...
var $count
function ...
# global $count; not needed anymore
$count++;
.
.
}
}
.
.
.
# At the end of your script.
# Nothing. $count is your variable, it's registered, coo coo ka
choo
$HTTP_SESSION_VARS['count'] = $sess_object->count;
# This is actually inside a function
?>
I do not know if this is bad because the way $HTTP_SESSION_VARS[] is
designed or what. Just wanted to know if there is some real problem like
references or some problem that would cause data missing or becoming
corrupt. Thanks.
Sean C. McCarthy
SCI, S.L. (www.sci-spain.com)
Richard Lynch wrote:
>
> > 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 richard@zend.com address is an endangered species -- Use
> ceo@l-i-e.com
> 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