-3
我已經將PHP版本從5切換到7,並且在連接到數據庫期間發生以下錯誤。PHP消息:PHP注意:未定義變量:conn
FastCGI的在標準錯誤發送:「PHP消息:通知PHP:未定義變量:CONN在/www/admin/Connection.php線14上
- 從命令行到數據庫的連接是OK 。
連接,從標準的PHP代碼數據庫確定爲好。
<?php class Connection { private static $conn; private $dbHost; private $dbUser; private $dbPass; private $dbName; public $dbHandle; public $languages; public static function getConnection() { if($conn == null) self::$conn = new Connection(); return self::$conn; } protected function __construct() { $this->dbhost = BV_DB_HOST; $this->dbuser = BV_DB_USER; $this->dbpass = BV_DB_PASS; $this->dbname = BV_DB_NAME; $this->dbConnect(); } public function dbConnect() { $this->dbHandle = mysqli_connect(BV_DB_HOST, BV_DB_USER, BV_DB_PASS); $tmp = mysqli_select_db($this->dbHandle, BV_DB_NAME); mysqli_query($this->dbHandle, "set names utf8"); return $tmp; } public function languages() { return explode(";", BV_LANGS); } } ?>
我該如何解決該問題?