title: Get Folder Name Of Current Directory
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9997391/php-get-name-of-current-directory">PHP Get name of current directory</a>  </p>
  </blockquote>
  
  
  
  <p>Today I tried to get the folder name of a directory. I was successful to an extent. But it did not meet my criteria. The code which I have is as follows.</p>
  
  <pre><code>&lt;?php
  $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : $_SERVER['REQUEST_URI'];
  $foldername = basename($url);
  echo $foldername;
  ?&gt;
  </code></pre>
  
  <p>This returns the final value in an URL. I mean if the URL is <code>localhost/default</code> it returns <code>default</code> and when the url is <code>localhost/default/index.php</code> it returns <code>index.php</code>. I want it to return <code>default</code> in both the cases. </p>
  
  <p>So is it possible to get the thing which I am expecting ?? Please help me out with that..</p>