title: How To Identify The Requested Page In PHP
body: <p>Is there any easy way to identify the file initially handling the request, ignoring get arguments and handling (at least basic) mappings like <code>/</code> to <code>/index.php</code>?</p>
  
  <p>Ideally what I'm looking for is something like <code>$_SERVER['REQUEST_URI']</code>, except it returns the same value regardless of the get arguments and that value is the file requested, not the URI, nor the currently executing file (<code>$_SERVER['PHP_SELF']</code>).  In other words, a <code>$_SERVER['REQUESTED_FILE']</code> or something.  I haven't seen anything like that.  Does it exist, or do I need to write something manually?</p>
  
  <p><strong>Update</strong>
  Here are some example URLs paired with what I would like the result to be:</p>
  
  <pre><code>example.com/mypage.php       : /mypage.php
  example.com/                 : /index.php
  example.com/foo/?hello=world : /foo/index.php
  </code></pre>
  
  <p>And these return values are true even in included files.  See my answer below before answering, I think I've found what I was looking for.</p>