"Allex" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> What's the syntax for including/requiring files located in directories
> different than the root directory? Especially files from different sub
> directories under the root? Going down ("classes/globals.php") is ok,
> but going up ("../globals.php") makes problems
>
> Example:
>
> index.php:         include_once('classes/globals.php') -> works fine;
> dbase.php:         include_once('../globals.php') -> generates an error;
> controller.php:    include_once('../dataaccess/dbase.php') -> error;
>
> root (dir)
> +-classes (dir)
> |  +-interface (dir)
> |  | |-controller.php
> |  +-dataaccess (dir)
> |  | |-dbase.php
> |  |globals.php
> |index.php
> |

What you probably need to do to go 'up' a directory is something like this:
$dir = dir($_SERVER['SCRIPT_FILENAME']);

Then take off the last directory.  Then either stay there or append another
directory name to it.
Try using strrchr().  Or there is probably a class somewhere to break a path
into all its parts.

  -- Rob



>
> I'm running PHP 4.3.2 with Apache 2 on WinXP box.
>
> Thanks,
> Allex

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

Reply via email to