Question

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!

Was it helpful?

Solution

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'];

OTHER TIPS

You can use the Request URI variable.

$_SERVER['REQUEST_URI']

$data = basename($_SERVER['PHP_SELF']);
$data .= $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top