"Call to undefined function mysql_connect()" 升级到 php-7 后

"Call to undefined function mysql_connect()" after upgrade to php-7

在我将 php5 升级到 php7 之后,我收到错误 500 with

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

我将其放入我的 apt 资源中以便立即获得 php7:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

我基本上做的是:

apt-get remove php5
apt-get install php7-*

我正在使用当前版本的 Debian Jessie。

但我还是明白了。这里有很多关于 SO 的问题,我肯定都检查过了。但是我还没有找到答案。

来自PHP Manual

Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alternatives to this function include:

mysqli_connect()

PDO::__construct()

使用MySQLiPDO

<?php
$con = mysqli_connect('localhost', 'username', 'password', 'database');