Advanced Search

Results 1 to 4 of 4

Thread: $_SERVER['QUERY_STRING']-php

  1. #1
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question $_SERVER['QUERY_STRING']-php

    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...

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    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

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by Mike
    From the query string? Wouldn't that particular case be covered by the REQUEST_URI property?
    Yes, but the query string would work too.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •