FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Will this set or get a SESSION variable?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Will this set or get a SESSION variable? [message #180834 is a reply to message #180828] Thu, 21 March 2013 00:14 Go to previous messageGo to previous message
daveh is currently offline  daveh
Messages: 18
Registered: March 2013
Karma:
Junior Member
On Mar 20, 6:53 pm, Christoph Becker <cmbecke...@gmx.de> wrote:
> David Heller wrote:
>> I have the following code snippet:
>
>>    if(in_array($name, $this->m_names))
>>            {
>>                    $this->m_rules[$name][] = $rule;
>>                    return $_SESSION[$name];
>
>>            }
>> In the entire script there does not appear to be any assignment to the
>> $_SESSION super global
>> so would it be fair to say that "return $_SESSION[$name];" not only
>> creates a session variable but returns it also? And what is it set
>> to?? It appears to me that $_SESSION[$name] = " " or possibly
>> something else.
>
> You may check it out for yourself:
>
>         if(in_array($name, $this->m_names))
>                 {
>                         $this->m_rules[$name][] = $rule;
>                         var_dump($_SESSION[$name]);
>                         return $_SESSION[$name];
>
>                 }
>
> If the session is not initialized or the session variable has not been
> set before, it will print NULL.
>
> You'll find comprehensive information about PHP sessions on
> <http://www.php.net/manual/en/book.session.php>.
>
> --
> Christoph M. Becker

I'm starting to think that it does not matter if its set to anything
because I think what the author is trying to do is just get what
$name contains for instance if the $name is equal to Robert and he has
something like "$anothername = Robert" and then does this:
$_SESSION[$anothername]
then the contents would be equal: $_SESSION[$name] ===
$_SESSION[$anothername] So what he is really doing is returning the
"key" to an associative array since
$name is a member of $m_names and its also a key for $m_rules. Very
clever and interesting technique of passing by value.

Dave
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: APC issues: locking up all processes and lack of PHP 5.4 support
Next Topic: question about class getters
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 04:42:11 GMT 2024

Total time taken to generate the page: 0.03778 seconds