title: Getting base url in PHP
body: <p>Sorry I moved from PHP CodeIgniter to Pure PHP; I dont know how I can get the base url;</p>
  
  <p>This is what I have attempted:</p>
  
  <pre><code>echo($_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] .'../template.jpg');
  </code></pre>
  
  <p>the out put is:</p>
  
  <pre><code>localhost:8080/my_scheduler/shedule.php../template.jpg
  </code></pre>
  
  <p>What I need is the following:</p>
  
  <pre><code>localhost:8080/my_scheduler/template.jpg
  </code></pre>
  
  <p>the following code:</p>
  
  <pre><code>$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']
  </code></pre>
  
  <p>gives me the url for current PHP Script I want to go back and get the reqalpath(); but realpath did not work either!</p>
  
  <p>the following code dies not echo anything!</p>
  
  <pre><code> echo realpath($_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] .'../template.jpg');
  </code></pre>
  
  <p>Please let me know if you need more clarification!</p>
  
  <p>Thanks</p>