title: How do you create URL paths without using directories with PHP?
body: <p>I am trying to create URLs in PHP and use the path (<strong><em>$path</em></strong>) in <strong>if statements</strong>. </p>
  
  <p>At work, we use ASP Classic and have some file(s) that allows us to do things like:</p>
  
  <pre><code>&lt;%
   if path = "checkout" then
  
   &lt;!--#include file="ViewCheckout.asp"--&gt;
  
   elseif path = "billing" then
  
   &lt;!--#include file="ViewBilling.asp"--&gt;
  
   end if
  %&gt;
  </code></pre>
  
  <p>We can use the ' <strong>if path = "checkout"</strong> ' pretty much anywhere on our site. The curious thing is that '<strong>http://myworksite.com/checkout/</strong>' is the URL of the <strong>checkout</strong> page, yet there is no directory on our server called "<strong>checkout</strong>"... The above is just a couple of the list of '<strong>if path = "blah"</strong>' includes that appear in our 'start.asp' (The file that contains the base template of the pages).</p>
  
  <p>I've seen files like ParseURL.asp and other files (at work) that somehow create these URLs and allow us to use them globally. I am trying to learn how this is done in PHP (At work, we run Windows Server, I have a Linux box).</p>
  
  <p><strong>What I am trying to do is create the following URLs for their respective pages:</strong></p>
  
  <ul>
  <li><a href="http://mysite.com/browse/" rel="nofollow">http://mysite.com/browse/</a> - browse.php</li>
  <li><a href="http://mysite.com/contact/" rel="nofollow">http://mysite.com/contact/</a> - contact.php</li>
  <li><a href="http://mysite.com/top100/" rel="nofollow">http://mysite.com/top100/</a> - top100.php</li>
  </ul>
  
  <p><em>And again, I would like to create these URLs <strong>WITHOUT</strong> creating directories for the paths.</em></p>
  
  <p>I have read up on <strong>*http_build_url*</strong> and <strong>*parse_url*</strong>, but I am having a hard time determining the way to create URLs in the manner mentioned above.</p>
  
  <p><strong>The http_build_url tutorials I've found show this:</strong></p>
  
  <pre><code>&lt;?php
  echo http_build_url("http://user@www.example.com/pub/index.php?a=b#files",
      array(
          "scheme" =&gt; "ftp",
          "host" =&gt; "ftp.example.com",
          "path" =&gt; "files/current/",
          "query" =&gt; "a=c"
      ),
      HTTP_URL_STRIP_AUTH | HTTP_URL_JOIN_PATH | HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT
  );
  ?&gt;
  </code></pre>
  
  <p>The thing is, I can't figure out if this just outputs <strong>ftp://ftp.example.com/pub/files/current/?a=b&amp;a=c</strong> as text or if it is a way to create a valid URL... (This is obviously an FTP address...) - PHP.net</p>
  
  <p><strong>Note:</strong>
  At work, we can also use the <strong>if path = "contact"</strong> to include certain snippets like this:</p>
  
  <pre><code>&lt;%
   if path = "contact" or path = "chat" or path = "checkout" then
  
   &lt;div id="communication-nav"&gt;
    &lt;ul&gt;
     &lt;li&gt;Some link 1&lt;/li&gt;
     &lt;li&gt;Some link 2&lt;/li&gt;
     &lt;li&gt;Some link 3&lt;/li&gt;
    &lt;/ul&gt;
   &lt;/div&gt;
  
   end if
  %&gt;
  </code></pre>
  
  <p>If anyone can give me some pointers on how to re-create this using PHP, I would be very grateful!</p>
  
  <p>Am I researching the right functions? Do I need to use some sort of URL Re-write function?</p>