localhost/live - detect by HTTP_HOST

Posted by Adam Kiss on Stack Overflow See other posts from Stack Overflow or by Adam Kiss
Published on 2010-05-02T11:08:11Z Indexed on 2010/05/02 11:27 UTC
Read the original article Hit count: 138

Filed under:
|
|

Hello,

let's say I develop locally and debug small things on live server.

Is it good idea to have something like this in my code? :

$is_local = (strpos($_SERVER['http_host'], 'localhost') !== false);
define ('DEBUG',$is_local);

And then use it through my code, when setting stuff?

$mysql_settings = (DEBUG) ? 
  array(/*localhost settings*/) : 
  array(/*live settings*/);

This way, I can use the same files live and on localhost, so I can sync without any fear of having wrong e.g. connection settings on live server.

Is it good or wrong idea?

© Stack Overflow or respective owner

Related posts about php

Related posts about localhost