Reputation: 44061
My basic thoughts would be to do something like:
$isLocal = // test here
if ($isLocal) {
// local settings here
}
else {
// remote settings here
}
I've tried $_SERVER['HTTP_HOST'] but when I debug in Netbeans, HTTP_HOST does not appear as a parameter. Basically I'm looking for a robust test for $isLocal
Upvotes: 2
Views: 81
Reputation: 78912
You should probably keep distinct configuration files for each server and exclude them from your revision control system...
require_once '/config.local.php';
This has the advantage of scaling out to as many development servers as you want, while keeping the live configuration independent and private.
Upvotes: 2
Reputation: 5662
Can you pass a string via the $_GET
variable? If you were to add ?local=true
to your URLs and then test for this then this would be one way of accomplishing this quite easily. Just remember to disable when it goes live.
Upvotes: 0
Reputation: 3731
try
$_SERVER['SERVER_NAME'];
local address will be different from real
Upvotes: 0