Possible Duplicate:
PHP require file from top directory
I've been using PHP for a long time but I've always just written it to get the job done, now I'm trying to learn best practices and improve my skill. Right now I'm wondering what is the best method for including files in PHP scripts from any directory.
I have always done the following:
<?php
// From settings.php
define('ABSPATH', '/home/dalyn/public_html/');
// Then I put this at he top of all of my other files
include 'includes/settings.php';
include ABSPATH . 'includes/db.php';
include ABSPATH . 'includes/functions.php';
?>
But if my files are in a subdirectory I need to do something like:
<?php
include '../includes/settings.php';
include ABSPATH . 'includes/db.php';
include ABSPATH . 'includes/functions.php';
?>
Is there a better way to be doing this? I'm starting to learn OOP so if there is an OOP solution that applies I'm all ears.
Thank you.