-3

我不知道为什么我有这个错误。我正在使用 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;
            }
        }
    } 
?>
4

1 回答 1

1

你不见了

}

最终确定class Database {

为避免这种情况,请使用正确的行缩进并遵循Zend 编码样式指南

于 2013-08-08T08:48:29.537 回答