title: combine / include various PHP files into one single PHP file
body: <p>Hello Friends I am a newbie programmer and very very new to PHP. I am seeking help in writing a small php Function. The situation is like this:</p>
  
  <p>I am running Joomla and I have a template which is in BLOCKS for example:</p>
  
  <pre><code>header.php
  topmodules.php
  mainbody.php
  bottommodules.php
  footer.php
  </code></pre>
  
  <p>All my blocks are placed in a directory (/layouts/blocks). All these blocks need to be joined in the main Index.php file.</p>
  
  <p>The function I know is something like this:</p>
  
  <pre><code>&lt;?php
  function get_header(){
    require_once(TEMPLATEPATH.'/layouts/blocks/header.php');
  }
  ?&gt;
  </code></pre>
  
  <p>And then call it like:</p>
  
  <pre><code>&lt;?php get_header(); ?&gt;
  </code></pre>
  
  <p>But that is not very professional and also I will have to write a function for every file moreover this can also be accomplished by just using </p>
  
  <pre><code>&lt;?php require(YOURBASEPATH . DS .'layouts'. DS .'blocks'. DS . "header.php"); ?&gt;
  </code></pre>
  
  <p>But what I am looking for is to have a single function /class which can get that PHP file from that directory, just by passing the name of the file so that I can add some more blocks to that directory in future without re-writing the function and simply call them like:</p>
  
  <pre><code>&lt;?php $this-&gt;getBlock('header') ?&gt;
  &lt;?php $this-&gt;getBlock('topmodules') ?&gt;
  &lt;?php $this-&gt;getBlock('mainbody') ?&gt;
  &lt;?php $this-&gt;getBlock('bottommodules') ?&gt;
  &lt;?php $this-&gt;getBlock('footer') ?&gt;
  </code></pre>
  
  <p>Kindly help.</p>