RE: [PHP-INST] Help! No POST/GET variables!
| From: | Robert V. Zwink | Date: | Wed, 14 May 2003 18:24:58 +0000 |
| Subject: | RE: [PHP-INST] Help! No POST/GET variables! | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-10897@lists.php.net to get a copy of this message | ||
PHP's function extract() might be a bit more elegant.
http://www.php.net/manual/en/function.extract.php
Robert V. Zwink
http://www.zwink.net
Here's from the comments in the manual:
destes (at) ix.netcom.com
13-May-2002 03:13
Extract provides an invaluable way to get around the possibility of the
PHP directive register_globals being off or on. If you're used to
register_globals being on, and you're worried that new PHP 4.2.0
implementations will mess up existing code (because it now defaults to
off), try using this:
if (!empty($_GET)) {
extract($_GET);
} else if (!empty($HTTP_GET_VARS)) {
extract($HTTP_GET_VARS);
}
if (!empty($_POST)) {
extract($_POST);
} else if (!empty($HTTP_POST_VARS)) {
extract($HTTP_POST_VARS);
}
That's from PHPMyAdmin (to give proper credit), and the same thing would
probably be useful elsewhere. Thanks,
Steve
-----Original Message-----
From: David Rydell [mailto:drydell@worldnet.att.net]
Sent: Wednesday, May 14, 2003 12:26 PM
To: Jeremy Mereness
Cc: php-install@lists.php.net
Subject: RE: [PHP-INST] Help! No POST/GET variables!
a loop like the following will create $var1, $var2... from
$_POST['var1'],
$_POST['var2']... etc
if ($_POST) {
reset ($_POST);
while (list ($key, $value) = each ($_POST)) { ${$key} = $value; }
}
same applies to $_GET, $_SERVER, $_COOKIE, $_ENV...
-----Original Message-----
From: Jeremy Mereness [mailto:jeremym@optonline.net]
Sent: Wednesday, May 14, 2003 12:02 PM
To: php-install@lists.php.net
Subject: Re: [PHP-INST] Help! No POST/GET variables!
You know, I had read about this somewhere as a new "feature" of PHP, but
didn't make the connection.
Thanks very much for the quick answer. It turns out my Linux distro
packages
PHP with global variables switched on by default, while getting PHP from
the
source will have them switched off. Up til now I'd never thought about
it.
I guess the idea is to write "cleaner" code making use of
$_POST[variable]
and $_GET[variable] structures? or is there a better method?
-- j
----- Original Message -----
From: "Daniel Moore" <danielm@gropep.com.au>
To: <jeremym@optonline.net>
Cc: <php-install@lists.php.net>
Sent: Wednesday, May 14, 2003 9:09 AM
Subject: Re: [PHP-INST] Help! No POST/GET variables!
> Is it a global variables thing?
--
PHP Install Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.473 / Virus Database: 271 - Release Date: 4/17/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.473 / Virus Database: 271 - Release Date: 4/17/2003
--
PHP Install Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php