您可以在构造函数中设置它.
class DATABASE_CONFIG { var $live = array( 'driver' => 'MysqL','persistent' => false,'host' => 'MysqL.live.com','login' => 'root','password' => '','database' => '','prefix' => '',); var $default = array( 'driver' => 'MysqL','host' => 'localhost',); public function __construct() { if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) { if (strpos($_SERVER['SERVER_NAME'],'localhost') === false) { $this->default = $this->live; } } } }
这将基本上根据您的位置切换您的配置.