title: PHP Use Include Inside Function
body: <p>Im trying to make a function that I can call as follows,</p>
  
  <pre><code>view( 'archive', 'post.php' );
  </code></pre>
  
  <p>and what the function really does is this.</p>
  
  <pre><code>include( 'view/archive/post.php' );
  </code></pre>
  
  <p>The reason for this is if in the future I expand the directory to be <code>view/archive/another_level/post.php</code> I dont want to have to go back everywhere in my code and change all the include paths.</p>
  
  <p>Currently this is what i have for my function, except it appears that the include is being call inside the function, and not being called when the function is called...</p>
  
  <pre><code>function view( $view, $file )
      {
          switch ( $view )
          {
              case 'archive'  : $view = 'archive/temp';   break;
              case 'single'   : $view = 'single';     break;
          }
  
          include( TEMPLATEPATH . "/view/{$view}/{$file}" );
      }
  </code></pre>
  
  <p>How can I get this function to properly include the file?</p>
  
  <p>EDIT:</p>
  
  <p>There were no errors being displayed. Thanks to @Ramesh for the error checking code, <code>ini_set('display_errors','On')</code> I was able to see that there were other 'un-displayed' errors on the included file, which appeared to have caused the file not to show up...</p>