基于控制变量的不同设置

OK, what I need is rather straightforward but I'm looking for the best, CodeIgniter-friendly, solution :

  • I've got a website based on CodeIgniter
  • I've got a local copy; when the local copy is edited, an online/live version is also updated

What I need :

  • Have it "detect" whether I'm running from Localhost or from the real server, and set up e.g. Database details accordingly (preferably by setting some "global" variable).

So, any ideas? How would you go about it?

I use:

if ($_SERVER['SERVER_NAME'] == 'localhost'){
    //local settings
} else {
    //live settings
}