Results 1 to 6 of 6
  1. #1

    $_SERVER['PHP_SELF']

    I've been using $_SERVER['PHP_SELF'], but to get the filename of the current page like "/index.php", but how can I get the other URL information?

    Such as, http://www.website.com/index.php?id=5

    I want to collect "/index.php?id=5" just like that. Is there a way to do this?
    TextAdMarket - http://www.TextAdMarket.com
    Supply & Demand Advertising

  2. #2
    Is it $_SERVER['REQUEST_URI']?
    TextAdMarket - http://www.TextAdMarket.com
    Supply & Demand Advertising

  3. #3
    Join Date
    Apr 2005
    Posts
    1,711
    I think you mean something like:

    PHP Code:
    <?PHP

    // get ?id=NUMBER
    $ID $_GET['id'];

    // determine if the variable type is a digit
    // typecast it as an integer, and determine if $ID > 0
    if (ctype_digit((int)$ID) && $ID>0) {
      
    // If so, print our page
      
    print "You requested page number: " $ID;
    }

    ?>

  4. #4
    Not exactly. The REQUEST_URI actually worked for me. I was trying to capture a big chunk of the address bar as a string.

    thanks!
    TextAdMarket - http://www.TextAdMarket.com
    Supply & Demand Advertising

  5. #5
    Join Date
    Sep 2004
    Posts
    105
    To see all the server variables available to you:

    PHP Code:
    <?php
    echo "<PRE>";
    print_r($_SERVER);
    echo 
    "</PRE>";
    ?>

  6. #6
    Join Date
    Apr 2005
    Posts
    1,711
    I also think this might help:

    http://us.php.net/parse_url

Posting Permissions

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