不建议使用:具有相同名称的方法

问题描述 投票:0回答:1

我遇到错误

不推荐使用:与类相同名称的方法在将来的PHP版本中将不再是构造函数; DbClass在第1237行的/storage/emulated/0/htdocs/once.php中已弃用构造函数

function actionSql() {
    class DbClass { //1237 line
        var $type;
        var $link;
        var $res;
        function DbClass($type) {
            $this->type = $type;
        }
        function connect($host, $user, $pass, $dbname){
            switch($this->type) {
                case 'mysql':
                    if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
                    break;
                case 'pgsql':
                    $host = explode(':', $host);
                    if(!$host[1]) $host[1]=5432;
                    if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true;
                    break;
            }
            return false;
        }
php deprecated
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.