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 #180836 is a reply to message #180826] Thu, 21 March 2013 03:32 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/20/2013 6:09 PM, 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. There is a bunch of $_SESSION[$somevariable]'s in the
> code I'm looking at. The only reason I care is I would like to not
> have to use any super globals at all but until I can figure out what
> the original author was doing I'm stuck. I have successfully updated
> his code (written in 2001) to work with php 5.3 but its not production
> ready as register_globals has to be on and that's not a good thing. I
> have googled and have seen no example of this type of use of $_SESSION
> or $GLOBALS either.
>
> If you need to see more code please email me directly
>
>
> Thanks
>

No, if the array element doesn't exist, you will get a E_NOTICE message.

Not a good way to program. Rather, you should be using isset() to
ensure the array element exists before trying to use it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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:48:49 GMT 2024

Total time taken to generate the page: 0.05681 seconds