How can I replace $_SERVER["DOCUMENT_ROOT"] in PHP 7.0?

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

 



I have a website that was created years ago with PHP handlers for database
access etc. After upgrading the webhotel PHP version to 7.0 from 5.3 the site
functionality broke!

The main php file store is in htdocs/php but there are other places where these
files are referred to as includes using this syntax:

include ($_SERVER["DOCUMENT_ROOT"] . '/php/appdbdata.php');

And these includes are used in many places at different folder depths in the
site.
But now the only way I have found to handle this is to use relative paths and it
does not work well for files that are moved between directories.

QUESTION:
---------
What can I use in PHP 7 in order to include php files relative to document root?

I have tried googling but I always get to hardcodes solutions which is not good
when files are in different directories.

For the php files residing inside /php I simply replaced the construct with
(example):

include_once ('appdbdata.php');

THen seemingly all worked, but only until a call was made to a php file at a
deeper location which also included this file...


-- 
Bo Berglund
Developer in Sweden



[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