我不知道为什么我有这个错误。我正在使用 WampServer。我正在尝试通过 OOP 配置我的数据库,但我遇到了这个错误。
解析错误:语法错误,意外的 '?>',期待函数 (T_FUNCTION)
<?php
Class Database{
private $_host = null;
private $_user = null;
private $_pass = null;
private $_db = null;
var $con = false;
public function connects($host, $user, $pass, $db){
$this->_host = $host;
$this->_user = $user;
$this->_pass = $pass;
$this->_db = $db;
$this->con = mysql_connect($this->_host, $this->_user, $this->_pass);
if(!$this->con){
return false;
}
else{
$sql = mysql_select_db($this->_db);
if(!$sql){
return false;
}
else{
return true;
}
}
}
?>