views:

38

answers:

3

Hy everyone

i have a problem with my path

say i have a PHPfile in /home/bla/www/dev/source/test.php

in this test.php i want to include a file in

/home/bla/www/config/conf.php

<?php

include_once("");

?>

i dont want to include it like include /home/bla/www/config/conf.php

How can i do it? PS. this fails

include_once("../../config/conf.php");
+1  A: 
$current_dir = dirname(__FILE__);
require_once($current_dir.'/../foo/bar.php');

Note that require_once('foo.php') looks for foo.php in the same directory as the script, but require_once('../foo.php') is not relative to the path of the script, but relative to the current working directory.

Sjoerd
A: 

as DaDaDom suggests, permissions may well be the problem here. Have you tried addressing the file using an absolute path ( /home/bla/www/config/conf.php ), and if it fails, what'S the error?

moritz
This is a comment, not an answer
Phill Pafford
+2  A: 

I'd suggest to use absolute path instead of relative

include_once($_SERVER['DOCUMENT_ROOT']."/config/conf.php"); 

whould work from any folder

Col. Shrapnel
Note that this won't work if the script is run on the command line.
Sjoerd
Thanks this worked for me
streetparade