[SOLVED] forums have globals on, why?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

Well what are those other-advantages then?
I really wonder this whole register_global branch
If you have a detailed paper about them, plz share it..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

[big_search]register_globals[/big_search]
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

good work ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd recommend not using $_REQUEST, because it's a merger of $_GET, $_POST and $_COOKIE. The problem lies in what order the elements get set in, which can vary from installation to installation.

If you want to support such a mechanism, I'd suggest rolling your own version so you know the order of creation.
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

hmm, it sounds interesting, lets roll ours.
how can we do it?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

function getRequest()
{
  $vars_to_pull_from = array('_GET' , '_POST');
  reset($vars_to_pull_from);
  $output = array();
  while(list(,$var) = each($vars_to_pull_from))
  {
    reset($$var);
    while(list($k,$v) = each($$var))
      if(!isset($output[$k])) $output[$k] = $v;
  }
  return $output;
}
or similar...

the order you want the data is how $vars_to_pull_from is set up. So, if you want $_POST vars set first, you set it first in the array and so on..
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

hmmm good work, thanx...
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

Warning: Variable passed to reset() is not an array or object in c:\apache\htdocs\adven\develop\f.php on line 8
Warning: Variable passed to each() is not an array or object in c:\apache\htdocs\adven\develop\f.php on line 9
Warning: Variable passed to reset() is not an array or object in c:\apache\htdocs\adven\develop\f.php on line 8
Warning: Variable passed to each() is not an array or object in c:\apache\htdocs\adven\develop\f.php on line 9


:( i'm working on it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you did set $vars_to_pull_from correctly, yes?
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

:oops: shoud i do it inside of the function or outside of it?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can do it in either, just have to add some additional things for being done outside the function.

I could continue, but we're getting substantially offtopic. PM me, and we'll work out your details.
Post Reply