Superglobals blues

This is a discussion on Superglobals blues within the PHP Language forums, part of the PHP Programming Forums category; I need to access exaclty one of the superglobals arrays and don't want to use $_REQUEST. Having the name ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-09-2003
Dalibor Karlovic
 
Posts: n/a
Default Superglobals blues

I need to access exaclty one of the superglobals arrays and don't want to
use $_REQUEST. Having the name of the form method used on submit in
$this->sMethod and the name of the feild submited in $sName, I've tried

${'$_'. strtoupper($this->sMethod)}[$sName]

but it doesn't work. Writting a form generation/validation class, that is
why I need this. If somebody has an idea...

I've found that accessing superglobals like this won't work (which is true
:) and that they need to be referenced. How?

TIA

--
Dado

Chicken Little only has to be right once.
Reply With Quote
  #2 (permalink)  
Old 09-09-2003
Dalibor Karlovic
 
Posts: n/a
Default Re: Superglobals blues

Dalibor Karlovic wrote:

[replying to myself]

> I need to access exaclty one of the superglobals arrays and don't want to
> use $_REQUEST. Having the name of the form method used on submit in
> $this->sMethod and the name of the feild submited in $sName, I've tried
>
> ${'$_'. strtoupper($this->sMethod)}[$sName]


$sMethod='_POST';
$aData = &$$sMethod;
var_dump($aData);

In a relugar script it prints out content od $_POST, but inside a class it
prints out NULL. The exact same code. What am I missing here?

--
Dado

God is a comic playing to an audience that's afraid to laugh
Reply With Quote
  #3 (permalink)  
Old 09-09-2003
Dariusz Gorzeba
 
Posts: n/a
Default Re: Superglobals blues

On Tue, 09 Sep 2003 12:29:40 +0200, Dalibor Karlovic wrote:

> Dalibor Karlovic wrote:

[cut]
>
> $sMethod='_POST';
> $aData = &$$sMethod;
> var_dump($aData);
>
> In a relugar script it prints out content od $_POST, but inside a class it
> prints out NULL. The exact same code. What am I missing here?


$sMethod='_POST';

global $$sMethod;

$aData = &$$sMethod;
var_dump($aData);

--
-----
Dariusz Gorzęba
godotow_[AT]poczta[DOT]onet[DOT]pl
Reply With Quote
  #4 (permalink)  
Old 09-09-2003
lawrence
 
Posts: n/a
Default Re: Superglobals blues

Dariusz Gorzeba <godot_@poczta.onet.pl> wrote in message news:<1ermxiakmio9t$.ib7vnxzlpure.dlg@40tude.net>. ..
> On Tue, 09 Sep 2003 12:29:40 +0200, Dalibor Karlovic wrote:
>
> > Dalibor Karlovic wrote:

> [cut]
> >
> > $sMethod='_POST';
> > $aData = &$$sMethod;
> > var_dump($aData);
> >
> > In a relugar script it prints out content od $_POST, but inside a class it
> > prints out NULL. The exact same code. What am I missing here?

>
> $sMethod='_POST';
>
> global $$sMethod;
>
> $aData = &$$sMethod;
> var_dump($aData);


why?
Reply With Quote
  #5 (permalink)  
Old 09-10-2003
Dalibor Karlovic
 
Posts: n/a
Default Re: Superglobals blues

Dariusz Gorzeba wrote:

>> In a relugar script it prints out content od $_POST, but inside a class
>> it prints out NULL. The exact same code. What am I missing here?

>
> $sMethod='_POST';
>
> global $$sMethod;
>
> $aData = &$$sMethod;
> var_dump($aData);


This works, but superglobals are supposed to be globally accessible without
global. I'm confused :) But anyway, thank you very much.

--
Dado

.... Bleakness ... Desolation ... Plastic forks ...

Reply With Quote
  #6 (permalink)  
Old 09-10-2003
Dariusz Gorzeba
 
Posts: n/a
Default Re: Superglobals blues

On 9 Sep 2003 14:58:15 -0700, lawrence wrote:

>> $sMethod='_POST';
>>
>> global $$sMethod;
>>
>> $aData = &$$sMethod;
>> var_dump($aData);

>
> why?


i think ..
when script is compiled the variable and its range are setup and
there are set as local, even _POST,
_POST, becouse it's built after compilation, it is local too

if i'm wrong - correct me, please..

--
-----
pzdr
Dariusz Gorzęba
godotow_[AT]poczta[DOT]onet[DOT]pl
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0