Re: Setting or Getting Relative Path for PHP Includes

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

 



As already suggested there are $_SERVER variables that can assist you here. Although if you plan on having an include file that will be included by every script in your site you could also use the __FILE__ constant. In your case the following would work:

// main.inc.php, located in /home/virtual/sitename.com/var/www/html/
$path = dirname(__FILE__) . '/';

// now all relative includes with $path prefix should correctly resolve
// to absolute pathnames

--
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