-7

i getting issue fetch current url .php?id=1 get id

i am using this code

$query = $_SERVER['PHP_SELF'];
$path = pathinfo( $query );
$what_you_want = $path['basename'];

get .php but not get id

3 Answers3

0
$_SERVER['REQUEST_URI']

For more details on what info is available in the $_SERVER array, see the PHP manual

If you also need the query string (the bit after the ? in a URL), that part is in this variable:

$_SERVER['QUERY_STRING']
Vivek Singh
  • 2,453
  • 1
  • 14
  • 27
0

Use GET to get the value of id . You don't need to use $_SERVER['PHP_SELF'].

$id  = $_GET['id'];
sarath
  • 698
  • 6
  • 20
0

you can try this code

function curPageURL() {
     $pageURL = 'http';
         if ($_SERVER["HTTPS"] == "on") {
             $pageURL .= "s";
            }
           $pageURL .= "://";
            if ($_SERVER["SERVER_PORT"] != "80") {
                $pageURL .= $_SERVER["SERVER_NAME"] . ":" .              $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
        } else {
         $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
          }
        return $pageURL;
        }
Naeem Shah
  • 15
  • 5