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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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? |
|
|||
|
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 ... |
|
|||
|
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 |