私のデータベースの詳細を含むsettings.ini.phpファイルがあります。
;<?php return; ?>
[SQL]
host = localhost
user = root
password =Gohead123$
dbname = nri_demo
そして
**db.class.php**
private function Connect()
{
$this->settings = parse_ini_file("settings.ini.php");
echo '<pre>';
print_r($this->settings);exit;
$dsn = 'mysql:dbname='.$this->settings["dbname"].';host='.$this->settings["host"].'';
try
{
# Read settings from INI file, set UTF8
$this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
# We can now log any exceptions on Fatal error.
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
# Disable emulation of prepared statements, use REAL prepared statements instead.
$this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
# Connection succeeded, set the boolean to true.
$this->bConnected = true;
}
catch (PDOException $e)
{
# Write into log
echo $this->ExceptionLog($e->getMessage());
die();
}
}
私は、パスワード何も表示と設定(settings.ini.php)ファイルを解析する場合。私は
[SQL]
host = localhost
user = root
password =Gohead123
dbname = nri_demo
のようにパスワードを変更した場合、私は私がこの問題を解決するにはどうすればよい
Array
(
[host] => localhost
[user] => root
[password] => Gohead123
[dbname] => nri_demo
)
のような出力を得る?私を助けてください。
私のために働いて、? –
@Chethan Ameta PHPのバージョン7.0.15 –
'parse_ini_file($ str、false、INI_SCANNER_RAW)' –