system path, for different servers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
natatkinson
Forum Newbie
Posts: 4
Joined: Wed Jul 23, 2008 3:02 pm

system path, for different servers

Post by natatkinson »

I've developed a web application that I would like to be able to distribute to a few people.

Right now, each page has a include to a config.php file that has all the site info that needs to be changed for a different server (upload path, site url, header, footer locations, database info...). So currently, if I want install the application on another server, i need to do a sitewide search in dreamweaver (or the likes) and change the link sitewide. The link is like (/home/user/domains/domain/public_html/admin/includes/file.php).

Is there an easier way to do this so I don't have to change it for each server? I'm betting there is and I don't know it. I don't even know what to search for, so hopefully someone can point me in the right direction.

EDIT:
I tried $_SERVER["SITE_HTMLROOT"];

and that gave me nothing.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: system path, for different servers

Post by VladSun »

You may use paths like:

Code: Select all

realpath(".")."/include/config.php"
http://www.php.net/realpath
There are 10 types of people in this world, those who understand binary and those who don't
natatkinson
Forum Newbie
Posts: 4
Joined: Wed Jul 23, 2008 3:02 pm

Re: system path, for different servers

Post by natatkinson »

that seems to work well, although I need to make the path different for each folder, but thats not a big deal.

Thank you very much!!!!!
Post Reply