Search code examples
phpsuperglobals

What is the alternative of $_SERVER['PHP_SELF']?


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!


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