[nycphp-talk] What is $QUERY_STRING ?

CHUN-YIU LAM chun_lam at
Wed Mar 12 15:28:02 EST 2003

Why do you need QUERY_STRING?  PHP does separate the name-value pair to 
$_GET array.

----Original Message Follows----
From: Matthew Zimmerman <mz34 at>
Reply-To: talk at
To: NYPHP Talk <talk at>
Subject: [nycphp-talk] What is $QUERY_STRING ?
Date: Tue, 11 Mar 2003 11:09:05 -0500
Received: from ([]) by 
with Microsoft SMTPSVC(5.0.2195.5600); Tue, 11 Mar 2003 08:09:33 -0800
Received: from ( [])by (8.12.6/8.12.6) with ESMTP id h2BG95JH064800for 
<chun_lam at>; Tue, 11 Mar 2003 11:09:30 -0500 (EST)(envelope-from 
null at
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Message-Id: <200303111609.h2BG95JH064800 at>
X-Paralist-Archived: <>
X-List-Software: Paralist 0.6
List-ID: <>
List-Owner: <mailto:listmaster at>
List-Archive: <>
List-Subscribe: <>
List-Unsubscribe: <>
Organization: New York PHP
X-Mailer: Paramail 0.5
Return-Path: null at
X-OriginalArrivalTime: 11 Mar 2003 16:09:34.0967 (UTC) 

Ok, this may sound like a really naive question, but I will ask anyway.

What is the predefined variable $QUERY_STRING ? The PHP manual says:

The query string, if any, via which the page was accessed.

That definition is a bit tautological:) I ask because I have some code
I grabed from a website and it contains the line:

<form action="<?=$PHP_SELF?><?if($QUERY_STRING){ echo"?".

I am guessing this means if the form has been submitted, the key/value
pairs will be contained in a variable called $QUERY_STRING, but maybe I
am way off there?

Just to test I made a simple form:

<form action="test2.php" method="post">

Name<input type="text" name="name">
Address<input type="text" name="address" >
Title<input type="text" name="title" >
<input type="submit" name="Submit"">

I sent that to


$x= $_POST[name];
$y= $_POST[address];
$z= $_POST[title];

print ("$x ");
print ("$y ");
print ("$z ");
print ($QUERY_STRING);

But nothing prints out for $QUERY_STRING. I tired both POST and GET.

Thanks! I am asking this question mostly out of curiosity. The code I
downloaded works fine. I just want to know why it works.


--- Unsubscribe at ---

MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.

More information about the talk mailing list