Where to put database connection settings?
问题 Where do you put the connection settings for a database connection (things like host, dbname, user, password)? Is it placed in the database class or file, or outside in a config file, or somewhere else? 回答1: Ideally, you should place it in a config file, which can be something as simple as a PHP array. For example: db_config.php $db_config = array( 'host' => 'localhost', 'user' => 'username', 'password' => 'qwerty' ); You should then place this file outside your document root for maximum