title: How to get URL last part with php
body: <p>I was searching for solutions to display the current URL of the page, and I found a few ones but I don't know how to implement them and call them, so this was the best solution I've found for me because it already has the echo thingy.</p>
  
  <pre><code>function curPageURL() {
       $pageURL = 'http';
       if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
       $pageURL .= "://";
       if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
       } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
       }
       return $pageURL;
      }
  </code></pre>
  
  <p>And to call it, I'm calling it like this</p>
  
  <pre><code>echo curPageURL();
  </code></pre>
  
  <p>But I want to get only the last part of the URL, for exemple:</p>
  
  <pre><code>http://stackoverflow.com/posts/29237151/thequestion
  </code></pre>
  
  <p>I want to get <code>thequestion</code> part of the URL. how can I do this?</p>