You can get the query string added as well by doing
<?php
$file = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$file .= '?'.$_SERVER['QUERY_STRING'];
}
echo $file;
?>
Use $HTTP_SERVER_VARS instead of $_SERVER if you are using PHP version 4.0.6 or lower.
Mac