 <p>What you described is essentially the <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="nofollow">Model-View-Controller</a> paradigm used by most web application frameworks. MVC is designed to separate business logic from presentation. </p> <p>I can't really give you a more specific answer since your question is very vague, but the simplest, most stripped-down way to accomplish MVC is to have two php files, one accessible from the outside, which then includes another file in a protected directory.</p> <p>So for example you can have a functions.php file and then in your index.php file</p> <pre><code>require_once('lib/functions.php'); //call functions defined in functions.php </code></pre> <p>Aside from that, I think you just need to read up a bit and experiment on your own.</p>