Re: relative paths with "require"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you need relative require's, I have always found the constant __FILE__ to be useful. Just something like:


require_once (__FILE__ . "../b/b.php");


If you go this route, be sure to check out the user notes on the page here: http://us2.php.net/constants


Joey Morwick wrote:

Hello, I'm experiencing a problem with PHP4. On the server where our code
used to reside, the relative path used in an include started from the
directory in which the file containing the require statement resided. On
our new server, the relative paths seem to start from where the first php
script in the chain of "require"'s resides.


An example would be three files in two directories as follows:

/test/index.php
/test/a/a.php
/test/b/b.php

index.php: require("a/a.php");

a.php:
        require("../b/b.php");

On our old server, this would be fine, as the path searched in a.php would
start in /test/a.  On the new server, if you start processing index.php,
you will get a file not found error in a.php since it's starting from the
path "/test".

I've tried every config option I can think of and am nearly ready to try to
hack in a workaround.  Does anyone know how this could be configured?

Thanks,


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux