Q:

absolute/relative paths for php includes

I have a function(orders) with many php includes in a file called extract.php
http://example.com/application/dir1/dir2/dir3/extract.php
function orders ($username)
{
 require ("functions.inc.php");
 define("DATAGRID_DIR", "./../datagrid/");
 define("PEAR_DIR", "./../datagrid/pear/");
 require_once (DATAGRID_DIR . 'datagrid.class.php');
 require_once (PEAR_DIR . 'PEAR.php');
 require_once (PEAR_DIR . 'DB.php');
 require_once ('./../datagrid/classes/database.class.php');

//function code here
}

I have another file(install.php) that calls this function inside the same directory and it works very well.
<?php
include ("extract.php");
orders ("643443876996");
?>

However, when i include it in another function in this path 
http://example.com/orders/getorder.php, it gives me error that it cannot find my files 'datagrid.class.php';
    <?php
    include ("include('../application/dir1/dir2/dir3/extract.php');");
    orders ("643443876996");
    ?>

How can I get the path referencing correct?

A:

Reference from the server root, either with $_SERVER['DOCUMENT_ROOT'] or
require_once (DATAGRID_DIR . '/application/dir1/dir2/dir3/datagrid.class.php');
etc...

