Log in

View Full Version : $_SERVER['QUERY_STRING']-php



manashi_130582
04-18-2006, 05:21 AM
hi...
i want to know when we should use $_SERVER['QUERY_STRING']
and how it works..
the code is ..


<?php

$tmp = $_SERVER['QUERY_STRING'];
$tmp = explode("=",$tmp);
$id = $tmp[1];

if(!$id)
{
echo "<p>No id passed";
include("footer.html");
return;
}
?>
<h3>Question Paper Splitup</h3>
<h4>The exam has been successfully created! Your Exam id is
<?php echo "$id"; ?>.</h4>


Waitin 4 the reply... :)

Twey
04-18-2006, 09:32 AM
Usually, never. It can be used for special cases such as to get the path to the current directory from the browser's point of view. For the above, $_GET['id'] will work fine.

P.S. close that <p> tag!

mwinter
04-18-2006, 09:42 AM
It can be used for special cases such as to get the path to the current directory from the browser's point of view.From the query string? Wouldn't that particular case be covered by the REQUEST_URI property?


P.S. close that <p> tag!Not necessary, though it is something that I always do. The more important markup problem is the erroneous use of heading elements. Never use a heading element - of any level - just because you think it looks right. For a start, it may not in someone else's browser but, more importantly, nothing but headings should be marked-up by heading elements.

Mike

Twey
04-18-2006, 09:51 AM
From the query string? Wouldn't that particular case be covered by the REQUEST_URI property?Yes, but the query string would work too.