473,394 Members | 1,699 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,394 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 3919
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.