I believe that many people will comment and uncomment blocks (or individual lines) of code when switching between local and live running of their pages. This can be a pain. I use the following code and just change a value from
true to
false when moving to the remote/live site:
PHP Code:
<?php
if (!defined('LOCAL')) {
define('LOCAL', true); // set this to true or false
}
if (!defined('DB_USER')) {
if (LOCAL) {
DEFINE('DB_USER', 'Andrew');
DEFINE('DB_PASSWORD', 'Password1');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_NAME', 'AndyDB');
DEFINE('EMAIL', 'andy@somemail.com');
DEFINE('BASE_URL', 'http://localhost:80/AndysProject/');
} else {
DEFINE('DB_USER', 'user2');
DEFINE('DB_PASSWORD', 'Password2');
DEFINE('DB_HOST', 'www.some.com');
DEFINE('DB_NAME', 'db2');
DEFINE('EMAIL', 'host@someother.com');
DEFINE('BASE_URL', 'http://andyshost.com/');
}
}
?>
I store this in a config.php file that is included in relevant pages.