【发布时间】:2014-04-05 12:58:05
【问题描述】:
我正在尝试编写一个 php 论坛 OOP 样式的代码,但我遇到了一些困难这是我第一次编写 OOP 样式并且我不断收到错误
第 5 行出现意外的 T_VARIABLE
这是我的代码
<?php
class dbManager{
var $MySQL_Conx;
var $details = configManager::getConfig;
var $mysqli = $this->dbConnect();
public function dbSelect($sql, $mysqli){
}
private function dbConnect(){
$this->CloseConnection()
$this->MySQL_Conx = mysqli_connect($this->details['dbhost'], $this->details['dbuser'], $this->details['dbpass'], $this->details['dbdatabase'])
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
} else {
return $MySQL_Conx;
}
}
}
?>
configManager::getConfig; 也返回一个包含所有详细信息的数组以连接到数据库。
【问题讨论】:
-
在
$this->MySQL_Conx = mysqli_connect...末尾加分号 -
刚刚犯了同样的错误:/ @fred-ii
-
你使用的是什么版本的 PHP
-
你在
$this->CloseConnection()也忘记了一个@user2710382 -
你是否知道 PHP 5.0 是在一段时间前发布的......就像 10 年前