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, H开发者_运维技巧TTP_HOST does not appear as a parameter. Basically I'm looking for a robust test for $isLocal
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.
try
$_SERVER['SERVER_NAME'];
local address will be different from real
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.
精彩评论