title: Equivalent of escape(window.location.href) in PHP
body: <p>I have tried so many combination to  get the correct path of my page like the javascript code </p>
  
  <pre><code>escape(window.location.href)
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]$_SERVER[QUERY_STRING]";
  </code></pre>
  
  <p>but it returns something like:</p>
  
  <pre><code>http://www.mydomain.com/node/4158?asdf=1asdf=1
  </code></pre>
  
  <p>when the actual page is:</p>
  
  <pre><code>http://www.mydomain.com/node/4158?asdf=1
  </code></pre>
  
  <p>and if I have this URL: <code>http://www.mydomain.com/node/4158#comments</code> for example the result is:</p>
  
  <pre><code>http://www.mydomain.com/node/4158
  </code></pre>
  
  <p>i.e. without "#comments"</p>