hi

I have a file, index.php that's including another file in an other directory, say, /classes/class1.php.

From class1.php, I want to require_once additional files from that directory, but it appears that the PHP is looking at everything pertaining to the first file, index.php, in the require_once filepath.

Within the class1.php, I want to say require_once("class2.php") and I want it to look in /classes.

So, what's the best way to get the actual file location for a given file, NOT pertaining to any includes or etc??? I don't want to hardcode the full path because I'll be moving the files around to different servers. Is there a way to determine a given file's location on the fly, without being affected by any previous includes/requires?

Thanks
frizzo

    have a variable called $MODROOT or something to that effect which will store the path till the application, then append it to get the final path

    $MODROOT = "/home/httpd/web";//path to the application, can change from server to server
    include($MODROOT."/class/file2.php");
    

    reg
    kevin

      hmm, yeah, that's that the app I'm working with currently does. I'd still like to know if a page can simply know where it is!!

        Write a Reply...