473,233 Members | 1,393 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,233 software developers and data experts.

$HTTP_SERVER_VARS['SCRIPT_FILENAME'] - getting all GET vars too?

Hi,

I am using $HTTP_SERVER_VARS['SCRIPT_FILENAME'] to get the name of the
current web page. How do I also get the GET variables using PHP as a
complete string. For example:

'?first=12&second=value&third=2.99'

As I dont know what the variables may I cant simply use $_GET. Ideally
something like FOR EACH $_GET to generate the GET part of the url. Any
ideas? Cheers

Burnsy
Jul 17 '05 #1
3 3918
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo.co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VARS['SCRIPT_FILENAME']
$_SERVER would be preferred, but it's the same info.
to get the name of the
current web page. How do I also get the GET variables using PHP as a
complete string. For example:

'?first=12&second=value&third=2.99'
Look at $_SERVER['QUERY_STRING']

phpinfo() is useful for dumping out all the superglobals, or you could just
var_dump($_SERVER) etc.; you can then see which ones may have the information
you need.
As I dont know what the variables may I cant simply use $_GET. Ideally
something like FOR EACH $_GET to generate the GET part of the url.


Well, yes exactly that.

foreach ($_GET as $key => $val)

... same as any associative array. There could be arrays in there though which
are treated a bit differently. It's all available in $_SERVER['QUERY_STRING'],
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
.oO(Andy Hassall)
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo.co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VARS['SCRIPT_FILENAME']
$_SERVER would be preferred, but it's the same info.


Same info, but not the same scope. $_SERVER is superglobal, the old
$HTTP_* arrays are not.
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;


This can also be done with modifying 'arg_separator.input' if possible.

Micha
Jul 17 '05 #3
On Mon, 06 Dec 2004 14:13:29 +0100, Michael Fesser <ne*****@gmx.net> wrote:
.oO(Andy Hassall)
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo.co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VARS['SCRIPT_FILENAME']


$_SERVER would be preferred, but it's the same info.


Same info, but not the same scope. $_SERVER is superglobal, the old
$HTTP_* arrays are not.


True.
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;


This can also be done with modifying 'arg_separator.input' if possible.


Well, having that set might be _why_ you'd want to rewrite URLs to use ';'
instead of '&' (which browsers tend to send), rather than _how_. I tend to have
arg_separator.input set to '&;', and write out URLs separated with ';' mostly
because it's easier than escaping & into &amp; all over the place.
arg_separator.output handles anything where PHP constructs URLs, but I think
that's mostly just the form rewriting it does for cookie-less sessions.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4

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

Similar topics

5
by: lawrence | last post by:
I've this function, which is the method of a class. I'm posting the constructor of the class down below. For some reason, when I fill out a form and hit submit, I'm not getting any values. Can...
4
by: Preston Crawford | last post by:
I'm working on a site that's being developed on Apache/Linux and going to be hosted on IIS/Windows. Anyone know of a site with good tips on possible pitfalls, things to look for. Typical things...
3
by: none | last post by:
Hi all, now if I've understood the code below correctly, if I add the line; $session_dean_id = $hResult('dean_id'); At the bottom I will create a new variable named '$session_dean_id' which...
0
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits...
21
by: Thomas Mlynarczyk | last post by:
Hello, My provider has set register_globals = On and I can't change the php.ini file. Is there a way to unset all the imported get/post etc. variables at the beginning of my script? Thomas
1
by: Bob Bedford | last post by:
Hi, I've this code in my form: <?php ini_set('use_trans_sid',1); session_cache_limiter('private, must-revalidate'); if(!session_is_registered("UID")){ session_start(); $UserID = 0; if...
2
by: Dogstar | last post by:
I am trying to add a 'feedback' button on every page on a website. I want to add the button to the page footer which is accessed on each page using the include function. I want the feedback button to...
3
Jezternz
by: Jezternz | last post by:
Easy to get the external ip adress, using the $SERVER var, but I want the local ip. My situation isnt normal by the way. Basicly im building simple intranet ( i want to run this on a local area...
13
matheussousuke
by: matheussousuke | last post by:
Does anyone use oscommerce in there;; In modules and in another partas of the shop I'm having the followin troubleÇ -------------------------- Autoriza��o de pagamento_br_utilizando o...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.