Domanda

My current address is: http://localhost/bookstore/bookedit.php?book_id=12

The $_SERVER['PHP_SELF'] variable is a string '/bookstore/bookedit.php',

But I would like to get the string 'bookedit.php?book_id=12',

Do we have any function or variable can do this?

Thanks!

È stato utile?

Soluzione

If you do a var_dump($_SERVER) you will see all of the server variables you have available to you

$_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];

Altri suggerimenti

You can use the Request URI variable.

$_SERVER['REQUEST_URI']

$data = basename($_SERVER['PHP_SELF']);
$data .= $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top