title: Why are these relative paths not working in php
body: <p>My app structure is as follows</p>
  
  <pre><code>application -&gt; views -&gt; templates
                               // some more files
                       page.php
              -&gt; controllers 
                       home.php        
              -&gt; models 
                       items.php
              router.php
  index.php
  </code></pre>
  
  <p><strong>First case:</strong></p>
  
  <p>Index.php</p>
  
  <pre><code>include 'application/routes.php';
  </code></pre>
  
  <p>Routes.php </p>
  
  <pre><code>require "controllers/home.php";
  </code></pre>
  
  <p>controllers/home.php</p>
  
  <pre><code>require '/application/models/clusters.php'; //works
  require 'application/models/clusters.php'; //works
  require '../models/clusters.php'; //doesn't work
  </code></pre>
  
  <p>Why do the first lines work but not the last?</p>
  
  <p><strong>Second case:</strong></p>
  
  <p>Index.php</p>
  
  <pre><code>include 'application/views/page.php';
  </code></pre>
  
  <p>Page.php</p>
  
  <pre><code>glob("application/views/templates/*.php") // array of files
  glob("templates/*.php") // empty array
  </code></pre>
  
  <p>I think there's something wrong with my understanding of how paths work in php, but I can't figure out what it is. Sometimes paths seem to be relative to the current script, adn other times relative to index.php, but not necessarily tied to when I start the path with <code>/</code></p>