Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    113
    Thanks
    6
    Thanked 1 Time in 1 Post

    GET value without the variable name and equal sign in URL

    I've seen links like this: http://example.com/hello.php?4495

    as you can see, there is no variable name or equal sign in the above URL. Normally it would be like this:
    http://example.com/hello.php?v=4495

    Now in my hello.php script, how can I get the value 4495 even if the user entered the url without the equalsign or variable name?
    Last edited by eapro; 05-10-2009 at 11:19 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    PHP Code:
    preg_match('/[0-9]+/',$_SERVER['REQUEST_URI'],$match);
    print_r($match); 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    echo $_SERVER['QUERY_STRING']; // 4495 

  • Users who have thanked kbluhm for this post:

    eapro (05-11-2009)


  •  

    Posting Permissions

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