In fact, there are several modules that support MySQL (mysql, mysqli, pdo_mysql, ...). MySQLi (enhanced) is usually recommended for more complete support for MySQL5 functions compared to the mysql source module. PDO (PHP Data Objects) is a database abstraction layer that provides object-oriented data abstraction.
You can use function_exists() for previous comments if you want to check for a specific function for each module (mysql_connect, mysqli_connect, ...).
Alternatively, you can use the PHP extension_loaded() function to check the extension itself (module name corresponding to phpinfo () output)
<?php if (extension_loaded('mysql') or extension_loaded('mysqli')) {
At the command line, you can list all compiled modules with:
php -m
If you use a unix-ish system, use grep to filter output to MySQL-related modules:
php -m | grep -i mysql
If you are running on Windows, use findstr to filter output to MySQL-related modules:
php -m | findstr -i mysql
source share