champ
champ

Reputation: 817

fetching the url in php

my url is like below:

http://www.xyz.org/abc/list.php?id=1

now "$_SERVER['PHP_SELF']" gives me only "abc/list.php" this portion

and "$_SERVER['REQUEST_URI']" gives me "abc/list.php?id=1" this

now if i want to fetch only the portion "?id=1" how to do that. coz im having problems in the paging query for this.

thanxx in advance...

Upvotes: 0

Views: 1115

Answers (4)

Flask
Flask

Reputation: 4996

$_GET['id'] or $_REQUEST['id']

if your not sure which GET values u'll receive u also could

$fullRequest = exlode('?', $_SERVER['REQUEST_URI']);
$params = array();
foreach(explode('&', $fullRequest) as $part){
    foreach(explode('=', $part) as $keyVal){
        $params[$keyVal[0]] = $keyVal[1];
    }
 }

Upvotes: 0

bradym
bradym

Reputation: 4961

Take a look at http://php.net/parse_str, http://php.net/parse-url and http://php.net/http_build_query

Depending on what you're doing http://bradym.net/php/modify-query-string-parameters may also be helpful.

Upvotes: 0

MatTheCat
MatTheCat

Reputation: 18761

It's $_SERVER['QUERY_STRING'].

Upvotes: 3

Thariama
Thariama

Reputation: 50840

Use $_GET['id'] to access the id parameter.

Upvotes: 0

Related Questions