473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.
Jul 16 '05 #1
5 2066
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
Jul 16 '05 #2
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
Jul 16 '05 #3
Dariusz Gorzeba <go****@poczta.onet.pl> wrote in message news:<1e*****************************@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?
Jul 16 '05 #4
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 ...

Jul 16 '05 #5
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
Jul 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Geoff Berrow | last post by:
Just been checking out odbc. The notion of simply being able to upload an Access file seemed cool, but writing the queries is far from straightforward. Firstly there is the reserved word problem....
1
by: Heath | last post by:
Howdy, I am really struggling with the basics here. PHP/MySQL I have a database with three columns: ID, Name, Phone
2
by: xcomm | last post by:
Hi All, <?php $vars= array("_SERVER","_SERVER","_SERVER","_SERVER","_SERVER","_SERVER"); foreach($vars as $var) { if(isset($$var))echo("$var: ${$var}<br>\n"); } ?> php.net:
1
by: john | last post by:
The python libraries like urllib and httplib do not support ssl through a proxy. Urllib2 supports http through a proxy or https alone, but not https through a proxy. A while ago my wife...
1
by: Frank | last post by:
Hi, we are using oracle clients (Release 9.0.1.0.1 - Production) on an NT4 (Service Pack6) computers. the server is a W2K, (Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production With the...
2
by: Marc Champagne | last post by:
Hi folks! I have built a VB project in VS.NET 7 which also includes a deployment project. Everything builds ok. When I install the setup package, it installs without a glitch.
6
by: chrispclay | last post by:
Hi, i am having problems with using superglobals. I have been trying to use the $_GET and $_POST superglobals but no matter which one i use, it doesn't print out anything. It doesn't print out what i...
1
by: neridaj | last post by:
Hey, I'm wondering if it is a good idea to store $_POST, $_GET vars in an include file. I have a lot of repeating vars and was wanting to consolidate them into one file to be included whenever...
2
by: clai83 | last post by:
Hi everyone, I have a question regarding vulnerabilities related to PHP superglobals, in particular $_SERVER. I will have a website on a shared hosting environment, and I am unsure of the risks...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.