如何使用符号查询后回显当前URL?

I'm trying to echo the current url using php. But it's not working because

$_SERVER['QUERY_STRING'];

I'm using php 7.3

<?php
$link = $_SERVER['QUERY_STRING'];
$long_url = urlencode($link);
echo $long_url;
?>

The url path that I'm using:
https://www.com/r/?https://mega.nz/#!link!pass
but the result is:

https%3A%2F%2Fmega.nz%2F

So the query_string command is not including after # symbol but when I delete the # symbol the code is working properly.
Url path without # symbol:
https://www.com/r/?https://mega.nz/!link!pass
Result without # symbol:

https%3A%2F%2Fmega.nz%2F%21link%21pass

Try with this code:

$url_ = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" :  "http";

$url_ .= "://";

$url_ .= $_SERVER['HTTP_HOST'];

$url_ .= $_SERVER['REQUEST_URI'];

echo $url_;

Use this echo $_SERVER['REQUEST_URI'];

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