title: File_exists but won't include
body: <p>I'm trying to include a file but it doesn't seem to be working - here's the entire code:</p>
  
  <pre><code>if (file_exists('config/categories.php')) {
      include ('config/categories.php'); 
  } 
  
  foreach ($categories as $cat_sef =&gt; $cat_name) {
      echo '&lt;a href="'.$full_domain.$cat_sef.'" alt="#"&gt;'.$cat_name.'&lt;/a&gt;&lt;br /&gt;';
  }
  </code></pre>
  
  <p>The contents of config/categories.php is simply an array:</p>
  
  <pre><code>$categories = array("category-1" =&gt; "Category 1", 
  "category-2" =&gt; "Category 2", 
  "category-3" =&gt; "Category 3")
  </code></pre>
  
  <p>I know the file exists because the following works:</p>
  
  <pre><code>if (file_exists('config/categories.php')) {
      echo "file exists";
  }
  </code></pre>
  
  <p>However if I replace the array in categories.php with say:</p>
  
  <pre><code>echo "testing";
  </code></pre>
  
  <p>Nothing will display either. So as far as I can see, the file exists but it doesn't seem to be including some how. If I rename the categories file to something else I will receive a 'no such file' error (file does not exist).</p>
  
  <p>With the original code snippet, the error I get is:</p>
  
  <pre><code>Notice: Undefined variable: categories
  </code></pre>
  
  <p>But as you can see, it is defined in the categories.php file.</p>
  
  <p>The ONLY way it works is to put the array in place of the if (file_exists) part of my code, which I don't want to do because other parts rely on that categories.php file, so I don't want to dupe an array in multiple files.</p>
  
  <p>Does anyone have any idea what this could be? Let me know if you need any more info.</p>