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

Home » Imported messages » comp.lang.php » How to avoid the use of session variables in this script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
How to avoid the use of session variables in this script [message #180781] Mon, 18 March 2013 23:05 Go to previous message
daveh is currently offline  daveh
Messages: 18
Registered: March 2013
Karma:
Junior Member
Hello,

I have the following code snippet:

public function register($name, $rule, $dat_file, $server =
DEFAULT_SERVER, $port = DEFAULT_PORT)
{
if(in_array($name, $this->m_names))
{
$this->m_rules[$name][] = $rule;
return $_SESSION[$name];
}

// $cmd = "\$$name = new GTCM_GNP(\$dat_file, \$server, \
$port);";
// eval($cmd);

$$name = new GTCM_GNP($dat_file, $server, $port);
if(!$$name)
{
return FALSE;
}
$this->m_cnt++;
$this->m_names[] = $name;
$this->m_rules[$name] = array($rule);
return $$name;

What exactly does "return $_SESSION[$name]" do? it looks like it just
returns the $name argument in the function list. Or does it save it as
a session variable also? Why not just do: "return $name;" ?? Is there
a better way to do this without using session variables or super
globals? $_SESSION was originally $GLOBALS changing it to $_SESSION
did not break it and it seemed like a better alternative but probably
not the best way. By the way this code was originally written for php
4.0.6 if that makes any difference.

Thanks,

Dave
[Message index]
 
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: randomly sorting files in php
Goto Forum:
  

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

Current Time: Thu Nov 14 09:30:37 GMT 2024

Total time taken to generate the page: 0.06451 seconds