basename没有给我完整的URL PHP

Right now I'm printing the current URL I have and it kinda does it ok:

$currentURL = basename($_SERVER['PHP_SELF']);

The problem is that it only prints

solutions.php

instead of printing

solutions.php?id=581298a7-6c08-11e3-9bea-742f689f29f1

Anybody knows why this is happening? I need to get to print the part of

?id=581298a7-6c08-11e3-9bea-742f689f29f1

Because then I will be performing a substring to get just the ID.

Use parse_url, which parses a URL and returns its various components in a usable array. You'll also want to make sure you're parsing the correct string; in this case use:

$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

Full usage:

$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
print_r(parse_url($url));

This is expected behavior, because everything from the ? afterwards are not part of the filename. The parameters that you're looking for are in the $_GET superglobal.