This works (3 back, not 2)
PHP Code:
require_once '../../../php/Archive/Tar.php';
This works
PHP Code:
set_include_path ('../../../php');
require_once 'Archive/Tar.php';
This does not work
PHP Code:
require $_SERVER['DOCUMENT_ROOT'].'/path/to/file.php';
The script happens to be in a subdomain and $_SERVER['DOCUMENT_ROOT'] returns
Code:
/home/user/public_html/subdomain
which is in the public directory, not the root. In the main domain it would return
Code:
/home/user/public_html
not too reliable.
Much neglected __FILE__, on the other hand, returns
Code:
/home/user/includes/classes/Archive.php
which is better but still no help.
I'm sticking with absolute path
PHP Code:
set_include_path ('/home/user/php');
require_once 'Archive/Tar.php';
restore_include_path();
Thanks all!
EDIT - This also works:
PHP Code:
$path = $_SERVER['DOCUMENT_ROOT'];
$pos = strpos($path, 'public_html');
$path = substr($path, 0, $pos).'php';
set_include_path ($path);
require_once 'Archive/Tar.php';
restore_include_path();
Bookmarks