[PHP] Re: relative paths with require

2004-10-27 Thread Jason Barnett
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


[PHP] Re: relative paths

2001-11-17 Thread Gaylen Fraley

You've answered your own question.  If document-root is set to
/usr/web/htdocs then require(/somefile) will expect to find somefile in
document-root.

--
Gaylen
[EMAIL PROTECTED]
Home http://www.gaylenandmargie.com
PHP KISGB v2.22 Guestbook http://www.gaylenandmargie.com/phpwebsite

Mitja Pagon [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi!

 I want to know if there is a way to include(require) a file using a path
 relative to web server root.

 I'm aware of the fact that you can specify include path, but I believe
that
 this is not the best solution, since applications written that way aren't
 easily portable.

 What I'm looking for is something similar to what / does in HTML paths
and
 SSI include directives.

 Thanks,

 Mitja Pagon





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]