title: How do i find root url in php similar to server.mappath in .net
body: <p>i have a page where i need to pass multiple arguments via the url 
  i need to get the relative root path of the public_html folder .</p>
  
  <p>I tried some of the functions</p>
  
  <pre><code>$path=$_SERVER['DOCUMENT_ROOT'];
  echo __FILE__;
  $docRoot = $_SERVER['DOCUMENT_ROOT'];
  
  echo "&lt;br&gt;";
  $thisFile = str_replace('\\', '/', __FILE__);
  $webRoot  = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
  
  $srvRoot  = str_replace('library/config.php', '', $thisFile);
  echo $docRoot."&lt;br&gt;".$webRoot."&lt;br&gt;".$srvRoot;
  $p=getcwd();
  echo  "&lt;br&gt;".dirname ( $p );
  $my_folder = dirname( realpath( __FILE__ ) ) ;
  echo "&lt;br&gt;".$my_folder;
  echo "&lt;br&gt;".basename($_SERVER["SCRIPT_FILENAME"], '.php');
  </code></pre>
  
  <p>i get the path as "/home/elitenua/public_html/gallitest/index.php"</p>
  
  <p>i want the path as "/gallitest/index.php"</p>
  
  <p>Please help.</p>
  
  <p>Thanks in advance.</p>